Appendix 0
value representable in.
th~
cjes1:inati.on
format. Since the set
of
possible values
representable
by the destination format
is
always finite (although very large),
this "best
fit"
value
Vd
does exist and
is
unique. A conversion error
is
gener-
ated whenever
Vs
lies outside the range
of
the destination format unless
-1
<
Vs
<
1.
A
"faithful"
representation
of
the.
source number in the destination
format
is
defined
as
the unique number such that
Vd
best fits
Vs.
·0.5
Floating-Point
Error Exception Handling
D-6
Numerous errors
are
detectable by the TMS34010 C
floating-point
run-time
support functions, and you can trap
every error that
is
detected.
Each
error
Can
be trapped independently, so you
are
free to trap one type
of
error while ac-
cepting the default result on any
or
all others. This trapping is done by means
of
a user-defimible error exception handling routine called
fp-error.
This rou-
tine
is
called by the floating
point
package whenever one
of
the detectable
errors occurs. For a complete list
of
detectable errors,
see
Table
0-1,
page
0-7.
When
an
error is encountered,
fp-error
is
called using the C calling conven-
tion,
with
an
error number passed
as
an
argument.
An
example
of
fp-error
might
be:
void
fp
-
error
(err)
int
err;
(
switch(err)
(
1:
2:
3:
printf("CONVERSION
ERROR");
return;
5:
6:
7:
pr
intf
(
"ARITHMETIC
OVERFLOW");
return;
Note:
This example routine attempts no error recovery,
but
it
would
be
useful in
debugging
an
algorithm.