Control Builder - How to extract LSB & MSB from INT
Or I want to read LSB & MSB of a INTEGER to 2 separate signal ?
Voted best answer
There's no need for complicated conversions or fancy user code ...
Use the "TestBIT()" function to test any bit position in an integer You can also use the related "SetBit()" and "ClearBit()" functions to manipulate individual bits
Or you can just Bitwise AND with 16#1 for the LSB. Similarly you can Bitwise AND with 16#0F to get the lower 8 bits and 16#F0 to get the upper 8 bits.
The MSB of any Signed integer is always the "Sign" so if the value of an intger is negative the MSB is by definition "1" (explanation ... https://en.wikipedia.org/wiki/Two%27s...)