It's fascinating that the chunk operator is faster than the integer modulo or even the FP division.
The debate over computational efficiency and what you should and shouldn't do are interesting when you have BIG loops, but did anybody bother to figure out how many iterations it would take before you would even notice? You aren't using a tool like LC because you are worried about squeezing cycles. On Mon, Aug 5, 2013 at 9:05 PM, Mark Wieder <mwie...@ahsoftware.net> wrote: > Alex- > > The problem with things like mod and "/" is that they're expensive in > terms of scaling: they're about 3.5 times slower than "last char". If > you're just doing this once, it shouldn't matter much. But if you need > to determine oddness in a loop you want to do as much processing > outside the loop as possible. > > Here's the fastest I could come up with... > > constant kEven="02468" > put 3.14169 into tValue > -- do this outside the loop > put trunc(tValue) into y > put the milliseconds into x > repeat 10000 times > -- this line is slow > -- put the last char of trunc(y) is in kEven into tIsEven > -- much faster > put the last char of y is in kEven into tIsEven > end repeat > put the milliseconds -x > > -- > -Mark Wieder > mwie...@ahsoftware.net > > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > -- On the first day, God created the heavens and the Earth On the second day, God created the oceans. On the third day, God put the animals on hold for a few hours, and did a little diving. And God said, "This is good." _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode