• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Stupid newbie question - determine if integer is even or odd
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Stupid newbie question - determine if integer is even or odd
      • From: John Haager <email@hidden>
    • Re: Stupid newbie question - determine if integer is even or odd
      • From: Heather Donahue <email@hidden>
    • Re(2): Stupid newbie question - determine if integer is even or odd
      • From: Jens Bauer <email@hidden>
    • Re: Stupid newbie question - determine if integer is even or odd
      • From: John Hörnkvist <email@hidden>
References: 
 >Re: Stupid newbie question - determine if integer is even or odd (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: =?US-ASCII?Q?Re:_=3D=3FWINDOWS-1 252=3FQ=3FStupid=5Fnewbie=5Fque ?= stion_=97_determine_if_intege r?= is even or odd
  • Next by Date: Re: Stupid newbie question - determine if integer is even or odd
  • Previous by thread: Re: Stupid newbie question - determine if integer is even or odd
  • Next by thread: Re: Stupid newbie question - determine if integer is even or odd
  • Index(es):
    • Date
    • Thread