[Tutor] & syntax

W W srilyk at gmail.com
Tue May 27 12:48:01 CEST 2008


On Tue, May 27, 2008 at 4:50 AM, kinuthia muchane <muchanek at gmail.com> wrote:
> Hi,
>>>> 2&1
> 0
>>>> 3&1
> 1
>>>> 4&1
> 0
>>>> 5&1
> 1
>>>> 99&1
> 1
>>>> 100&1
> 0
>>>> 100&2
> 0
>
> Would someone kindly explain to me what is going on here. All I can see
> is even numbers return a '0' and odds a '1'. I also know all even
> numbers in binary  end in a zero. I had thought '&' was another way of
> writing the 'and' operator, seems I was wrong.

A quick Google search divulged the information that this is the
bitwise AND operator.

For more info:
http://en.wikipedia.org/wiki/Bitwise_operation

HTH,
Wayne


More information about the Tutor mailing list