Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello everyone i wrote following sentence

int temp = 7 & 9;

it returns 1..

can anybody explain it how.?
Posted

1 solution

Because the & operator performs bitwise AND operation between its operands:
C
9 & 7 = 1001b & 0111b = 0001b = 1


Remember, the truth table for AND operation is

&01
000
101
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900