[Tutor] Bitwise &

Joel Goldstick joel.goldstick at gmail.com
Wed Oct 14 20:08:17 EDT 2015


On Wed, Oct 14, 2015 at 7:39 PM, Laura Creighton <lac at openend.se> wrote:

> In a message of Wed, 14 Oct 2015 19:29:47 -0400, Joel Goldstick writes:
> >& is a bitwise operator, so any odd number and 1 will be one (true), and
> >any even number will be zero (false)
>
> You and Ben seem to have missed the problem in the answer.
> I think that Ni needs to understand _how bitwise operators work_
>
> And it is 1:38 here in the morning, I must get to bed.  Somebody
> else explain it!  (and if they don't, Ni, I will get to it tomorrow.)
>
> Laura
>
> Ok
the integers can be represented in binary like:  5 = 0101, 0 = 0000, 2 ==
0010, etc.

When you perform the & operation, it does a bitwise and operation.   0101 &
0001 = 1, 0010 & 0001 = 0.

 Hope that helps



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays


More information about the Tutor mailing list