I'm reading code for creating a digital oscillator. This part is storing sample values in a buffer.
On the line
short ss is shifted to the right, and then ss is used again on the next line.
The purpose of the code is to store two bytes of a short sequentially in the buffer,
but for the code to make sense wouldn't ss have to have it's original value on both lines, which means
the value of ss was not changed by >> 8? Otherwise, the first line gets rid of the least significant byte.
So, bit shifting operations don't change the value of the variable? That's my question.
Here's all the code. Comments are mine. Here's the source of the code:
http://www.drdobbs.com/jvm/music-components-in-java-creating-oscill/230500178
On the line
short ss is shifted to the right, and then ss is used again on the next line.
The purpose of the code is to store two bytes of a short sequentially in the buffer,
but for the code to make sense wouldn't ss have to have it's original value on both lines, which means
the value of ss was not changed by >> 8? Otherwise, the first line gets rid of the least significant byte.
So, bit shifting operations don't change the value of the variable? That's my question.
Here's all the code. Comments are mine. Here's the source of the code:
http://www.drdobbs.com/jvm/music-components-in-java-creating-oscill/230500178