• 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: =?WINDOWS-1252?Q?Stupid_newbie_que stion_=97_determine_if_intege r?= is even or odd
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: =?WINDOWS-1252?Q?Stupid_newbie_que stion_=97_determine_if_intege r?= is even or odd


  • Subject: Re: =?WINDOWS-1252?Q?Stupid_newbie_que stion_=97_determine_if_intege r?= is even or odd
  • From: Andrew Pinski <email@hidden>
  • Date: Tue, 13 Aug 2002 18:11:08 -0400

For old:
try a%2==1 (this is equal to a mod 2 or a divide 2 and the remainder is equal to 1).
or even better in CS terms a&1==1 (the first bit of 1 is on).

For even: change ==1 to ==0.

Thanks,
Andrew Pinski
_______________________________________________
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.

References: 
 >Stupid newbie question — determine if intege r is even or odd (From: Jan Van Boghout <email@hidden>)

  • Prev by Date: Re: =?WINDOWS-1252?Q?Stupid_newbie_que stion_=97_determine_if_intege r?= is even or odd
  • Next by Date: Re: Stupid newbie question ? determine if intege r is even or odd
  • Previous by thread: Re: =?WINDOWS-1252?Q?Stupid_newbie_que stion_=97_determine_if_intege r?= is even or odd
  • Next by thread: Re: Stupid newbie question ? determine if intege r is even or odd
  • Index(es):
    • Date
    • Thread