|
Section 14: Flags continue222
|
|
Range Error and Error Ignore Flags
|
|
Two flags in the HP-41C can be used to control how the calculator reacts to range
error (overflows and underflows) and all operating errors. Flag 24 is the range error
ignore flag flag 25 is the error ignore flag. These flags provide excellent error
detection and handling in your programs.
|
|
Flags 24 and 25 are both cleared each time you turn the calculator on.
|
|
Range Errors
|
|
Remember from part I of this handbook that any calculation that exceeds the
computation or
storage range of
the calculator is an error (except in
statistics calculations).
Normally, when such a calculation is attempted, the HP-41C immediately displays
OUT OF RANGE and the error-causing
function is not executed. Flag 24 allows you to ignore these out-of-range errors.
|
|
If flag 24 is set, the the HP-41C places
±9.999999999 × 1099 into
the affected register and execution continues. Notice that the range error ignore
flag is not cleared when the error occurs. Since flag 24 is cleared
(automatically) only when you turn the calculator on, you only need to set it one
time at the beginning of the program. All subsequent range errors will be ignored
by the calculator.
|
|
Specifically, a range error is an overflow where a number is generated that exceeds
±9.999999999 × 1099.
Underflows (numbers closer to zero than
±1 × 10–99) do not
cause the OUT OF RANGE message to be
displayed. Zeros are placed into the affected register. Other range errors that can
be ignored by flag 24 are listed in
appendix E.
|
|
For example, the following program demonstrates how flag 24 works. An infinite loop
in the program begins with 1 × 1010
and alternately multiplies and divides that number by
1 × 1010. Each time through the loop,
the result from the previous multiply is multiplied by
1 × 1010, and the result from the
previous divide is divided by
1 × 1010. You can watch as the
displayed numbers approach the overflow
(9.999999999 × 1099) and the
underflow
(0.000000000 × 1000). Since flag 24 is
set, the overflow error does not cause the program to stop.
|