I want to pack the lowest two bytes of an integer into another in integer, an stuck at this
for ( int i = 0; i < 8 ; i ++){
if ((bitmask & ( 1 << i)))
result |= 1 >> i;
}
Endian-independent solution:
x = ((y >> 0) & 0xFF) |
((y >> 8) & 0xFF);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With