Math problem
Bob Sneidar
bobs at twft.com
Fri Feb 17 16:21:08 EST 2012
Thanks all. Some ingenious ways of going about it. Never ceases to amaze me when I see all the ways of doing something when I thought there was only 1. :-)
Bob
On Feb 17, 2012, at 11:49 AM, Peter M. Brigham, MD wrote:
> 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
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list