Home
Certification Preparation
CompTIA
A+
turning off a particular bit in a number
ali0482
Which bit wise operator is suitable for turning off a particular bit in a number ?
Find more posts tagged with
Comments
undomiel
Odd question. If you turn off a bit in a number that changes the number. You would want to use &
i.e.
170 (10101010b) & 255 (11111111b) will yield 170, but if you do 170 (10101010b) & 207 (11001111b) you will get 138 (10001010)
As you can see when a bit is on (1) then the bitwise and will leave the corresponding bit in the state that it was in, but if the bit is off (0) then it will turn off the corresponding bit.
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of