note | On machines that do not implement the IEEE standard for floating-point math, CHECK_MATH does not properly maintain an accumulated error status. |
note | Trap handling is machine dependent. Some machines won’t work properly with traps enabled, while others don’t allow disabling traps. |
Value | Condition |
---|---|
0 | No errors detected since the last interactive prompt or call to CHECK_MATH. |
1 | Integer divide by zero. |
2 | Integer overflow. |
16 | Floating-point divide by zero. |
32 | Floating-point underflow. |
64 | Floating-point overflow. |
128 | Floating-point operand error. An illegal operand was encountered, such as a negative operand to the SQRT or ALOG functions; or an attempt to convert to integer a number whose absolute value is greater than 231 – 1. |
note | Not all machines detect all errors. |
; Array a will not fail as divisor.
a = [1.0, 1.0, 2.0]
; Second element in array b should cause a divide-by-zero error.
b = [1.0, 0.0, 2.0]
; Clear the previous error status and print error messages
; if an error exists.
status = CHECK_MATH(1, 0, Trap=1)
c = 1.0 / a
status = CHECK_MATH(0, 0)
PRINT, a, c, status
; PV-WAVE prints the following:
; 1.00000 1.00000 2.00000
; 1.00000 1.00000 0.500000
; 0
; Cause an integer divide-by-zero error.
d = 1.0 / b
; PV-WAVE prints the following:
; % Program caused arithmetic error:
; % Floating divide by 0
; % Detected at $MAIN$ .
status = CHECK_MATH(0, 0)
PRINT, b, d, status
; PV-WAVE prints the following:
; 1.00000 0.000000 2.00000
; 1.00000 1.#INF0 0.500000
; 0