Re: Stupid newbie question - determine if integer is even or odd
Re: Stupid newbie question - determine if integer is even or odd
- Subject: Re: Stupid newbie question - determine if integer is even or odd
- From: Steve Bird <email@hidden>
- Date: Tue, 13 Aug 2002 19:28:11 -0400
On Tuesday, August 13, 2002, at 06:32 PM, John C. Randolph wrote:
On Tuesday, August 13, 2002, at 03:20 PM, Kevin Elliott wrote:
if(myval % 2 == 0)
<curmudgeon>
I'd just like to point out that even though everyone else who answered
this question did a mod and compare, the result of the modulus operator
is an integer, which in C is a perfectly valid boolean value.
"These kids today don't know the simple joy of saving four bytes of
page-0 memory on a 6502" - unknown
</curmudgeon>
<Obsessed cycle-counter>
I'd just like to point out that even though everyone else who answered
this question did a mod , I did not see a single answer of
if (myVal & 0x1) {
}
--- ANDing is most often faster than division. It pains me to see a
division whose result (quotient) is discarded. That's just cruel. There
IS such a thing as the Society for the Prevention of Cruelty to Computers,
you know.
</Obsessed cycle-counter>
----------------------------------------------------------------
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.