I have a byte for example:
"10000110"
which is 97
in decimal.
I don't know the correct ordering, some places it is written "01100001"
, the point is that I'm speaking about the decimal number 97 which is stored in a single byte in our app.
We don't need bigger numbers than 100 in our app in this place of data and we would like to store an additional boolean data in the last (8th) bit in the corresponding byte, so..
- I would like to write a 0 in the 8th bit after I've read that bit for the boolean information.
So this way I will have my boolean data from the 8th bit, and after that I can write the 8th bit to zero, so I can read my byte to get the decimal number. (because we only use values from 0-100 the last bit should always be zero.)
I don't know if it is clear enough, please let me know if you have any questions.
So in short, my question is:
How could I write a 0 to the last bit of a byte in Java?