How do we turn off the rightmost bit off in a number?
No Comments...
Asked in TechnologyComputers- Asked 1 year ago By anonymous Views: 78
Answered 1 year agoanonymous
We "and" the number with one less the number.
Lets suppose the number is x then to turn the rightmost bit off in the number we do a x&(x-1)
Example
14 - 00001101
And it with 13 - 00001100
14 & 13 would give 12
00001101
& 00001100
---------------------
00001100
Bitwise representation of 12 is 00001100.Sign In to answer

RSS Feed
Follow us on twitter





