Re: odd and even numbers

2013-08-08 Thread william humphrey
I only said it was weird because the result was odd. Thanks everyone for your help, as always, and it's not my fault this thread degenerated into a golf clap/ whatever that is. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit

RE: odd and even numbers

2013-08-06 Thread Paul D. DeRocco
From: Mark Wieder Hmmm... for now, just ignore my benchmarks. I'm getting quite different results with LC 4.6.4 and LC 6.1rc1, and I think there's some garbage collection going on in the background. Plus I found half a dozen LC update processes running. I'm currently seeing fairly

Re: odd and even numbers

2013-08-06 Thread Mark Wieder
Paul- Monday, August 5, 2013, 10:59:27 PM, you wrote: I hope the engine is smart enough that repeat 1 times doesn't convert the count back and forth between a string and a number ten thousand times. repeat with the number of bottles of beer on the wall take one down convert it to a

RE: odd and even numbers

2013-08-06 Thread Paul D. DeRocco
From: Mark Wieder Paul- Monday, August 5, 2013, 10:59:27 PM, you wrote: I hope the engine is smart enough that repeat 1 times doesn't convert the count back and forth between a string and a number ten thousand times. repeat with the number of bottles of beer on the wall

Re: odd and even numbers

2013-08-06 Thread Mike Kerner
I think you forgot to pass it around. On Tue, Aug 6, 2013 at 2:25 AM, Paul D. DeRocco pdero...@ix.netcom.comwrote: From: Mark Wieder Paul- Monday, August 5, 2013, 10:59:27 PM, you wrote: I hope the engine is smart enough that repeat 1 times doesn't convert the count back

Re: odd and even numbers

2013-08-06 Thread Dr. Hawkins
On Tue, Aug 6, 2013 at 8:01 AM, Mike Kerner mikeker...@roadrunner.com wrote: I think you forgot to pass it around. Maybe it was a good brand? -- Dr. Richard E. Hawkins, Esq. (702) 508-8462 ___ use-livecode mailing list use-livecode@lists.runrev.com

Re: odd and even numbers

2013-08-06 Thread Mike Kerner
golf clap/ #winner On Tue, Aug 6, 2013 at 2:10 PM, Dr. Hawkins doch...@gmail.com wrote: On Tue, Aug 6, 2013 at 8:01 AM, Mike Kerner mikeker...@roadrunner.com wrote: I think you forgot to pass it around. Maybe it was a good brand? -- Dr. Richard E. Hawkins, Esq. (702) 508-8462

odd and even numbers

2013-08-05 Thread william humphrey
How do you test a number to see if it is a whole odd or even number? ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

Re: odd and even numbers

2013-08-05 Thread dunbarx
: odd and even numbers How do you test a number to see if it is a whole odd or even number? ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http

Re: odd and even numbers

2013-08-05 Thread Mike Kerner
Craig is such a party pooper. There have got to be ways that are more fun and demonstrate the breadth of the language to new users if x/2 contains . then answer odd else answer even if x/2 = x div 2 then answer even else answer odd hm what else? On Mon, Aug 5, 2013 at 4:17 PM, william

RE: odd and even numbers

2013-08-05 Thread Paul D. DeRocco
From: dunb...@aol.com Just ask yourself this answer testNumber mod 2 If you get a 1, testnumber is odd, if a 0, even. Careful, x mod 2 will be -1 for a negative odd number. Better to test for zero (even) or nonzero (odd). By the way bitwise AND normally works for negative or positive

Re: odd and even numbers

2013-08-05 Thread J. Landman Gay
On 8/5/13 3:25 PM, Mike Kerner wrote: Craig is such a party pooper. There have got to be ways that are more fun and demonstrate the breadth of the language to new users if x/2 contains . then answer odd else answer even if x/2 = x div 2 then answer even else answer odd hm what else?

Re: odd and even numbers

2013-08-05 Thread Richmond
On 08/05/2013 11:17 PM, william humphrey wrote: How do you test a number to see if it is a whole odd or even number? Probably try and divide it by 2 and see if there is a remainder. That's what Miss Neville taught me when I was 6. Richmond. ___

Re: odd and even numbers

2013-08-05 Thread Mike Kerner
OOH, I like Jacque's answer - THERE's one that just smacks other languages in the jaw - the only thing I might do is get rid of the commas - can't you do if the last char of x is in 02468? I like Paul's, too. That demonstrates a bit of power in the language. On Mon, Aug 5, 2013 at 4:44 PM,

Re: odd and even numbers

2013-08-05 Thread william humphrey
if x/2 = x div 2 then answer even else answer odd This one is weird. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

Re: odd and even numbers

2013-08-05 Thread Mike Kerner
that's ok, it works. On Mon, Aug 5, 2013 at 5:31 PM, william humphrey b...@bluewatermaritime.com wrote: if x/2 = x div 2 then answer even else answer odd This one is weird. ___ use-livecode mailing list use-livecode@lists.runrev.com Please

Re: odd and even numbers

2013-08-05 Thread kee nethery
OK I'll toss in a combo. put ((last char of trunc(x)) mod 2) = 0 into isOdd allows for a floating value of x which it should never be given but would be nice if it could handle allows for a quick mod calculation of a single digit rather than whatever the entire value of x is (perhaps speeds up

Re: odd and even numbers

2013-08-05 Thread Mike Bonner
set the itemdelimiter to . put (the number of items in (x/2) is 2) into isOdd On Mon, Aug 5, 2013 at 3:37 PM, kee nethery k...@kagi.com wrote: OK I'll toss in a combo. put ((last char of trunc(x)) mod 2) = 0 into isOdd allows for a floating value of x which it should never be given but

Re: odd and even numbers

2013-08-05 Thread Alex Tweedly
Can you please define the problem more precisely ? It seems to me there are 3 possible answers to come out from any solution (or maybe more) 1 -- odd 2 -- even 2.5 -- neither odd nor even (or, if you prefer, not whole) AFAICS, all the proposed solutions so far have been incomplete, because

RE: odd and even numbers

2013-08-05 Thread Paul D. DeRocco
From: Alex Tweedly Can you please define the problem more precisely ? It seems to me there are 3 possible answers to come out from any solution (or maybe more) 1 -- odd 2 -- even 2.5 -- neither odd nor even (or, if you prefer, not whole) AFAICS, all the proposed solutions so far

Re: odd and even numbers

2013-08-05 Thread Alex Tweedly
On 05/08/2013 23:53, Paul D. DeRocco wrote: . I thought the original question stated the assumption that the number was whole. Normally, one tests to see if a number is an integer by comparing it to its integer part. In LC you just ask if it is an integer. No, it didn't. That was precisely my

Re: odd and even numbers

2013-08-05 Thread Mark Wieder
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

Re: odd and even numbers

2013-08-05 Thread Mike Kerner
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

RE: odd and even numbers

2013-08-05 Thread Paul D. DeRocco
From: Mark Wieder 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. Is that because values are always converted to binary and back to a string when doing arithmetic, or because the arithmetic itself is done in

Re: odd and even numbers

2013-08-05 Thread Peter W A Wood
Paul On 6 Aug 2013, at 10:57, Paul D. DeRocco wrote: Is that because values are always converted to binary and back to a string when doing arithmetic, or because the arithmetic itself is done in BCD? Does anyone know how the engine works? Mark Waddingham kindly explains how the engine

RE: odd and even numbers

2013-08-05 Thread Paul D. DeRocco
From: Peter W A Wood Mark Waddingham kindly explains how the engine performs arithmetic in this QCC entry - http://quality.runrev.com/show_bug.cgi?id=9349 That page states that arithmetic is done on 64-bit floating-point values, which is what I always assumed, and suggests the possibility

Re: odd and even numbers

2013-08-05 Thread Mark Wieder
Mike- Monday, August 5, 2013, 6:38:09 PM, you wrote: It's fascinating that the chunk operator is faster than the integer modulo or even the FP division. The last char chunk can be determined quickly with a pointer. Math operators are turned over to the math library, which will necessarily be

Re: odd and even numbers

2013-08-05 Thread Mike Bonner
I assume using baseconvert has the same slowdown issue? A function call from library, so not as fast? put the last char of baseconvert(x,10,2) is 1 into isOdd On Mon, Aug 5, 2013 at 10:56 PM, Mark Wieder mwie...@ahsoftware.net wrote: Mike- Monday, August 5, 2013, 6:38:09 PM, you wrote:

Re: odd and even numbers

2013-08-05 Thread Mark Wieder
Hmmm... for now, just ignore my benchmarks. I'm getting quite different results with LC 4.6.4 and LC 6.1rc1, and I think there's some garbage collection going on in the background. Plus I found half a dozen LC update processes running. I'm currently seeing fairly consistent results with all the