swapbytes

Navigation:  Language Reference > Operators > Prefix >

swapbytes

Previous pageReturn to chapter overviewNext page

Syntax

swapbytes a

Description

swapbytes a swaps the bytes of a.

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 swapbytes 30 swaps byte D  to A, C to B, B to C and A to D (see figure below) which gives a decimal value of 503316480.

 

 

Bitoperators

Limitations

a and b must be integers.