http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Least significant bit?



// C/C++
x = n % 2;	
if (x == 0) // it's even

{ Pascal/Delphi }
x := n mod 2;
if x = 0 then { it's even }


-----Original Message-----
From: gameprogrammer-owner@gameprogrammer.com
[mailto:gameprogrammer-owner@gameprogrammer.com]On Behalf Of Lionel
Pinkhard
Sent: Wednesday, July 26, 2000 6:18 AM
To: gameprogrammer@gameprogrammer.com
Subject: Least significant bit?


Hi,

Can somebody tell me how to check the least significant bit (bit 0) of a
number?

What I'm trying to do is only to check whether a given number is even or
odd, and (please do correct me if I calculated incorrectly) I think that all
even numbers have 0 as the least significant bit, and all odd numbers have
1, am I correct? Also, is this
 the best/fastest way to do this kind of calculation, or is there something
better?

I've been thinking of doing this with some kind of AND/OR/XOR mask, but I
think that would get way too complex (after all, I'm only trying to read in
ONE BIT!)

Kind regards,

Lionel Pinkhard

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCꫨ please visit:
http://gameprogrammer.com/mailinglist.html
İİİİİİİİİİİİİİİİİİİİİÑe GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCꫨ please visit:
http://gameprogrammer.com/mailinglist.html