Math problem
Peter M. Brigham, MD
pmbrig at gmail.com
Fri Feb 17 14:49:55 EST 2012
On Feb 17, 2012, at 12:20 PM, Geoff Canyon Rev wrote:
> function roundUp x,i -- rounds x up to the next i
> return ((x - .00001) div i + 1) * i
> end roundUp
Works except for values like 4.000000001.
Try this instead. It's a sort of a trick to avoid using a conditional construction, though the logic is conditional in structure, but does it in one line. I couldn't find a way of doing it using just LC's math functions, maybe someone else can.
function roundUp x
return trunc(x) + char itemoffset((x mod 1 > 0),"true,false") of "10"
end roundUp
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig
More information about the use-livecode
mailing list