For a certain programming project, I need to perform operations on the “bottom two bits” of an int in java set to 0x0000, however I am not sure which end of the int is “bottom” and which is “top”.
For a certain programming project, I need to perform operations on the bottom two
Share
The terminology is usually “high order bits” are the most significant (the first ones) and “low order bits” are the least significant (the last ones). Bit positions are referred to by their zero-based position counting from the right, which corresponds with the numerical value of the bit being
2positionAssuming that “bottom” is synonymous with “low”, that would make the “bottom two bits” the last two bits, or bits in position
1and0.In java, you can get the those bits using a bit mask: