198
6-4. Hints for Programming High-level Instructions
4. Overflow and Underflow
1) Overflow and Underflow
• When performing some instructions, the operation result may exceed the maximum overflow or go below the
minimum underflow in the range of 16-bit or 32-bit data.
When an overflow or underflow occurs, the carry flag (R9009) turns ON.
2) Overflow and Underflow in Binary Operations (16-bit or 32-bit)
■
16-bit Binary Operation
■
32-bit Binary Operation
Example:
• Overflow
When DT0 = K32767 and DT1 = K1,
K-32768 is stored in DT100 and R9009 turns ON.
• Underflow
When DT0 = K-32768 and DT1 = K-1,
K32767 is stored in DT100 and R9009 turns ON.
X0
F22+, DT0, DT1, DT100
Underflow
Overflow
•
•
•
H 7FFFFFFF
K 1 H 00000001
K 0 H 00000000
K –1 H FFFFFFFF
•
•
•
•
•
•
•
•
•
K 2147483647
The maximum
value links with
the minimum
value.
Max. value
H 80000000
K–2147483648
Min. value
• Overflow:
The result becomes a negative minimum
value (K-2147483648/H80000000) if K1
is added to the positive maximum value
(K2147483647/H7FFFFFFF).
• Underflow:
The result becomes a positive maximum
value (K2147483647/H7FFFFFFF) if K1
is subtracted from the negative minimum
value (K-2147483648/H80000000).
Underflow
Overflow
•
•
•
H 7FFF
K 1
H 0001
K 0
H 0000
K –1
H FFFF
•
•
•
K–32768
H 8000
•
•
•
•
•
•
K 32767
The maximum
value links with
the minimum
value.
Max. value
Min. value
• Overflow:
The result becomes a negative minimum
value (K-32768/H8000) if K1 is added to
the positive maximum value
(K32767/H7FFF).
• Underflow:
The result becomes a positive maximum
value (K32767/H7FFF) if K1 is
subtracted from the negative minimum
value (K-32768/H8000).
Содержание FP1
Страница 1: ...PROGRAMMABLE CONTROLLER FP1 is a global brand name of Matsushita Electric Works Hardware ...
Страница 28: ...20 ...
Страница 98: ...90 ...
Страница 150: ...142 ...
Страница 208: ...200 ...
Страница 226: ...218 ...
Страница 280: ...272 ...