![FATEK FBs Series Manual Download Page 124](http://html1.mh-extra.com/html/fatek/fbs-series/fbs-series_manual_3764826124.webp)
5 -13
Increase
(Decrease)
Result
Overflow/
Underflow
16-bit Operand
32-bit Operand
Increase
OVF=1
−
32767
−
32768
32767
32766
32765
OVF=1
−
2147483646
−
2147483647
−
2147483648
2147483647
2147483646
Decrease
UDF=1
−
32767
−
32768
32767
32766
32765
UDF=1
−
2147483647
−
2147483648
2147483647
2147483646
2147483645
5.5
Carry and Borrow in Addition/Subtraction
Overflow/Underflow takes place when the operation of increment/decrement causes the value of the operand to exceed
the positive/negative limit that can be represented in the PLC, consequently a flag of overflow/underflow is introduced.
Carry/Borrow flag is different from overflow/underflow. At first, there must be two operands making addition (subtraction)
where a sum (difference) and a flag of carry/borrow will be obtained. Since the number of bits of the numbers to be added
(subtracted), to add (subtract) and of sum (difference) are the same (either 16-bit or 32-bit), the result of addition
(subtraction) may cause the value of sum (difference) to exceed 16-bit or 32-bit. Therefore, it is necessary to use
carry/borrow flag to be in coordination with the sum (difference) operand to represent the actual value. The carry flag is
set when the addition (subtraction) result exceeds the positive limit (32767 or 2147483647) of the sum (difference)
operand. The borrow flag is set when addition (subtraction) result exceeds the negative limit (
−
32768 or
−
2147483648)
of the sum (difference) operand. Hence, the actual result after addition (subtraction) is equal to the carry/borrow plus the
value of the sum (difference) operand. The FO of FBs-PLC addition/subtraction instruction has both carry and borrow flag
outputs for obtaining the actual result.
MSB
↓
LSB
↓
16-bit
/
32-bit
To Be Added (Subtracted) Operand
+
(
−
)
16-bit
/
32-bit
Addition (Subtraction) Operand
1-bit
Carry/Borrow
16-bit or 32-bit
Sum (Difference) Operand
While all FBs-PLC numerical operations use 2’S Complement, the representation of the negative value of the sum