182
Chapter 16: Working with Numbers
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
16.3. EXACT/APPROX/AUTO Modes
The EXACT/APPROX mode setting controls the way numbers are treated by the
computer algebra system. In simplest terms EXACT mode causes the simplifier
to convert float numbers to integers or fractions. APPROX mode causes the
simplifier to convert integers and fractions to float numbers. In AUTO mode the
simplifier does not alter the number types unless an operation must combine a
float number with a nonfloat number. When this combination occurs, the nonfloat
number is converted to a float number before they are combined.
Number conversions due to mode are performed by
push_internal_simplify
when it encounters each number. Lower level routines in the computer algebra
assume that the enforcement of the mode setting has occurred before they are
called. Thus, if an application calls
push_internal_simplify
,
push_simplify
, or
push_simplify_statements
to evaluate an expression, the numbers in the
expression will be handled according to the mode setting. However, if an
application directly calls lower level computer algebra routines with numeric
arguments, the mode setting will not be enforced.
For example, if the mode setting is EXACT, and an application passes the
expression 1.5 + 2 to
push_internal_simplify
, the result will be 7/2. The float
value 1.5 is automatically converted to 3/2. However, if the application passes
1.5 and 2 to the
push_sum
routine, the result will be 3.5.
push_sum
does not
enforce the mode setting, and the default action for combining floats and
nonfloats is to convert the nonfloat into a float.
To duplicate the computer algebra’s numeric behavior, an application has two
choices.
•
Always enter the computer algebra simplifier through one of the three main
entry points (
push_internal_simplify, push_simplify,
push_simplify_statements)
. Thus, the mode setting will be enforced by
push_internal_simplify
.
•
Take responsibility for checking the mode setting and when necessary,
applying the appropriate conversions to its numeric arguments before calling
lower level routines.
Finally, an application may decide to ignore the current mode setting and enforce
one of its own choosing. An example is the built-in graphing application. The
grapher saves the current mode setting, changes the mode setting to APPROX
while it is active, and restores the current mode setting when it finishes.
The current status of the EXACT/APPROX mode setting is maintained in the
global variable
NG_control.
The macros IS_ARITH_EXACT,
IS_ARITH_APPROX, and IS_ARITH_AUTO are used to test the status of the
mode. The macros SET_ARITH_EXACT, SET_ARITH_APPROX, and
SET_ARITH_AUTO are used to alter the mode setting.