184
Chapter 16: Working with Numbers
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
Tagged floating point values are the floats available externally to the users of the
calculators. TI BCD floating-point values (C floats) must be converted to tagged
floats before displaying or storing to a calculator variable, and all the special
floating-point values in the TI BCD floating-point system such as infinity and NAN
(may also be referred to as undefined or invalid float) must be converted to the
symbolic equivalents before being made available to the user. All of this is
automatically handled by
push_Float
.
Occasionally an application developer may want to check for C float values not
valid in a tagged float without doing the actual
push_Float
conversion. For
example, an algorithm that has been written using TI BCD floating-point values
may need to take different paths or throw an error based on whether the result of
a previous operation was infinity or undefined. Routines such as
is_float_transfinite
and
is_nan
are available for this purpose. See
Appendix A:
System Routines — Direct Floating Point Operations
for more routines that
test for other special values.
round14
can be used on any BCD16 value to round
the number of digits in the mantissa to 14.
ck_valid_float
rounds a BCD16 value
to 14 digits, underflows to 0 if the exponent is less than -999, and returns a
floating-point NAN if the original value is transfinite or the exponent is greater
than 999. If
push_Float
had been used, the floating-point transfinite values and
an exponent greater than 999 would have resulted in the symbolic equivalents on
the estack. However, the NAN allows the developer to continue with the
algorithm if desired but
is_nan
may be called directly after
ck_valid_float
to test
for the NAN instead.
Since tagged floats have 14 digit mantissas, sometimes a series of operations
performed with tagged floats may get a different result from the one obtained by
doing the same series using BCD16 floats which have 16 digit mantissas.
Usually the 16 digit mantissas result in greater accuracy and are preferred for
that reason but a developer may want to match the external result which the user
would see if he entered a particular expression on the command line, which
would cause it to be executed on the estack and therefore use tagged floats. The
BCD14 format is available for this purpose but it should be noted that a BCD16
value will not cast to a BCD14 value (i.e. there will still be 16 digits in the
mantissa after the cast), and an explicit
round14
must be done in this case . It is
recommended that tagged floats on the estack be used when trying to match
external user results and that BCD16 floats be used when greater accuracy is
desired.
See
Appendix A: System Routines — Direct Floating Point Operations
for
details on the system routines that operate on BCD16 (double) arguments. Most
of these routines compute and return a corresponding function value; for
example,
sin
,
cos
,
tan
,
ln
,
sqrt
, etc. Others test for special values, for example,
is_float_infinity, is_float_positive_zero
, etc. Some are conversion routines.
estack_number_to_Float
is the primary routine for converting any tagged