[Tutor] Finding even and odd numbers
taserian at gmail.com
Wed Sep 19 17:28:33 CEST 2007
> > The above snippet is taking advantage of a similar property of binary
> > numbers, which are base 2. What the above snippet is doing is checking
> > see if that last digit is a 0 or not (asking "not n&1" is equivalent to
> > asking "n&0", since that digit can only be a 0 or 1).
> Not quite. The &1 is simply checking the least significant bit in the
> word. n&0 will always give 0. not n&1 checks whether the last digit
> -is- or -isn't- 1.
Not at all, you mean. I was way off with that statement; I'll plead not
guilty by virtue of not having had enough coffee today.
<8-( (Wearing the dunce cap. . .)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor