I have to implement a method that writes a byte to an ostream
object. Let\'s just called this ostream
object strobj
. I also have a bit
Your int
consist of several bytes (most likely 2, 4 or 8 bytes). Similar to the concept of the least significant bit, the least significant byte is the byte that has the less weight in the value of the entire integer. Depending on the endianness of your system, it may be the first or last byte in terms of memory.
To extract the least significant byte, bitwise-AND the number with one byte worth of 1
s, i. e. 255:
int LSB = (someInteger & 0xFF);