Relays, Memory Areas and Constants
1-82
Expression of decimal numbers in PLC
Decimal number is basically processed in 16-bit or 32-bit binary.
The most significant bit (MSB) expresses negative or positive sign of the data. When
the MSB is “0”, data is regarded as having a zero or positive value and when the MSB
is “1”, data is regarded as having a negative value.
In the case of positive numbers, the bits following the most significant bit express the
size of the data.
Example 1: Expressing the decimal number “1868”
0 1 1 1 1 1 10 0 0 0 0 0 0 0 0
16,384
8,192
4,096
2,048
1,024
512
256
128
64
32
16
8
4
2
1
The data size is indicated by the other bits.
1,024 + 512 + 256 + 64 + 8 + 4 = 1,868
Most significant bit: 0 (positive value)
A negative number is expressed as a two’s complement (the bits of the 16−bit binary
data of the positive number are inverted and 1 is added to the result).
Example 2: Expressing the decimal number “-4”
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0
Binary expression of
decimal number “4”
Invert each bit
Add 1
Most significant bit: 1 (negative value)
Binary expression of
decimal number “−4”