Navigation:  Language Reference > Operators > Binary >


Previous pageReturn to chapter overviewNext page


y= a bitshiftright b


a bitshiftright b shifts the bits of a with b places. Both a and b are treated as 32-bit (4-byte) integer values, so an eventual fraction will be ignored.

A positive value of b shifts the bits to the right and a negative value shifts the bits to the left.


In 20-sim all variables are stored as doubles. This means a decimal value of 30 is 4 bytes as shown in the figure below. Because the binary representation of 30 is equal to 11110, only the last byte is filled with non zero bits. The operation 30 bitshiftright 1 shifts the bits of 11110 with one place which gives 1111. This number has a decimal value of 60.




a and b must be integers. B should be in the range: [-31..31]