Runtime-Support
Functions
-
Header
Files
6.1.4
Floating-Point
Math
(math.h,
errno.h)
The
math.
h header defines several trigonometric, exponential, and hyperbolic
math functions. These math functions expect double-precision
floating-point
arguments and return double-precision floating-point values.
The
math.
h header also defines three macros that
can
be used
with
the math
functions for reporting errors:
• EDOM
• ERANGE
•
HUGE-VAL
Errors can occur in a math function
if
the invalid parameter values
are
passed
to
the function or
if
the function returns a result that is outside the defined
range for the type
of
the result. When this happens, a variable named
errno
is set
to
the value
of
one
of
the
following
macros:
•
EDOM,
for domain errors (invalid parameter),
or
• ERANGE, for range errors (invalid result).
C
code that calls a math function can
read
the value
of
errno
to check
for
error conditions. The
errno
variable is declared in
errno.
h,
and defined in
errno.c.
When a function produces a
floating-point
return value that is
too
large
to
be
represented, it returns
HUGE-VAL
instead.
6.1.5
Nonlocal
Jumps
(setjmp.h)
The
setjmp.
h header declares a function, a macro, and a type that
are
used
for bypassing the
normal function call and return conventions.
• The type that
is
declared
is
jmp-buf,
which
is
an
array type suitable
for
holding the information needed
to
restore a calling environment.
• The setjmp macro saves its calling environment in its
jmp-buf
argu-
ment, for
later use by the /ongjmp function. The next invocation
of
longjmp, even in a different function, causes a
jump
back to the
point
at
which
setjmp was called.
6-5