bitinv

Navigation:  Language Reference > Operators > Binary >

bitinv

Previous pageReturn to chapter overviewNext page

Syntax

y= bitinv a

Description

bitinv a inverts all bits of a. a is treated as 32-bit (4-byte) signed integer values, so an eventual fraction will be ignored.

All one bits are changed to zero and all zero bits are changed to one..

Example

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 bitinv 30 inverts the bits of "00000000 00000000 00000000 00011110" (30) to "11111111 11111111 11111111 1110001"  which is -31 (as signed integer).
 

 

Bitoperators

Limitations

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