I need some help with bitwise operations. I have number(64 bit) were first 16 bits are meaningful, and I'd like to set rest of them to "1"
00000000 11000001 00000000 00000000 ... <- currrent value
00000000 11000001 11111111 11111111 ... <- result I am trying to achieve
P.S. Oh, yeah! Sometimes, to solve - you just need to write out your task:)
I got it: value |= (-1 << bitsCount);
bitsCount - count of my meaningful bits
Use the bitwise OR operator:
1111111111111111
2 = 216 - 1=FFFF
16