[Gambas-user] function to "wrap" a number between upper and lower bounds

Kevin Fishburne kevinfishburne at ...1887...
Wed Dec 12 23:33:43 CET 2012


I need a function like:

Wrap(number, lowerbound, upperbound)

such that Wrap(5,1, 3) will return 2. In other words, it "wraps" the 
number around the supplied bounds and returns where it "lands". I 
believe it would work similarly to assigning a value to a datatype 
outside its scope, like assigning 300 to a Byte type.

I looked up some solutions online and none of them really seemed to work 
properly and their comments were surrounded by debate. Is there an 
efficient way to do this, and does anyone think it would be a useful 
function to add to Gambas itself?

-- 
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271





More information about the User mailing list