ieee_sun(3M)ieee_sun(3M)NAME
ieee_sun, fp_class, fp_classf, fp_classl, isinf, isinff, isinfl, isnor‐
mal, isnormalf, isnormall, issubnormal, issubnormalf, issubnormall,
iszero, iszerof, iszerol, signbit, signbitf, signbitl, nonstan‐
dard_arithmetic, standard_arithmetic, ieee_retrospective - miscella‐
neous floating-point functions
SYNOPSIS
cc [ flag ... ] file ... -lsunmath -lm [ library ... ]
#include <sunmath.h>
enum fp_class_type fp_class(double x);
enum fp_class_type fp_classf(float x);
enum fp_class_type fp_classl(long double x);
int isinf(double x);
int isinff(float x);
int isinfl(long double x);
int isnormal(double x);
int isnormalf(float x);
int isnormall(long double x);
int issubnormal(double x);
int issubnormalf(float x);
int issubnormall(long double x);
int iszero(double x);
int iszerof(float x);
int iszerol(long double x);
int signbit(double x);
int signbitf(float x);
int signbitl(long double x);
void nonstandard_arithmetic(void);
void standard_arithmetic(void);
#include <stdio.h>
void ieee_retrospective(FILE *f);
DESCRIPTION
Some of these functions provide capabilities suggested in the Appendix
of ANSI/IEEE Std 754-1985.
fp_class(x) returns a value that identifies x as zero, subnormal, nor‐
mal, infinite, or a quiet or signaling NaN. The type enum
fp_class_type is defined in <floatingpoint.h>.
The following functions return 1 if the indicated condition is true, 0
otherwise:
isinf(x) x is infinite
isnormal(x) x is normal
issubnormal(x) x is subnormal
iszero(x) x is zero
signbit(x) x's sign bit is set
nonstandard_arithmetic() and standard_arithmetic() are meaningful on
systems that provide an alternative faster mode of floating-point
arithmetic that does not conform to the default IEEE Standard. Non‐
standard modes vary among implementations; nonstandard mode may, for
instance, result in setting subnormal results to zero or in treating
subnormal operands as zero, or both, or something else. stan‐
dard_arithmetic() reverts to the default standard mode. On systems
that provide only one mode, these functions have no effect.
ieee_retrospective(f) prints a message to the file described by FILE *f
listing all non-default floating-point modes and status in effect when
called, including accrued exception flags, rounding direction and pre‐
cision modes, trap-enable modes, and nonstandard arithmetic mode.
ieee_retrospective() is intended to be used at the end of a program to
indicate exceptional floating-point conditions that might have affected
the result.
A program can explicitly call ieee_retrospective() at any time. For‐
tran programs compiled with f95 in -f77 compatibility mode automati‐
cally call ieee_retrospective() before they exit. C/C++ programs and
Fortran programs compiled with f95 in the default mode do not automati‐
cally call ieee_retrospective(). The f95 compiler enables trapping on
common exceptions by default, so unless a program either explicitly
disables trapping or installs a SIGFPE handler, it will immediately
abort when such an exception occurs. In -f77 compatibility mode, the
compiler does not enable trapping, so when floating point exceptions
occur, the program continues execution and alerts the user to those
exceptions via the ieee_retrospective() output.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
┌────────────────────┬─────────────────┐
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
├────────────────────┼─────────────────┤
│Interface Stability │ Committed │
│MT-Level │ MT-Safe │
└────────────────────┴─────────────────┘
SEE ALSOcopysign(3M), fpclassify(3M), fex_set_log(3M), ilogb(3M), isfinite(3M),
isinf(3M), isnan(3M), isnormal(3M), nextafter(3M), remainder(3M),
scalbn(3M), signbit(3M), attributes(5), floatingpoint(5)NOTES
As required by C99, the <math.h> header file defines macros named
isinf(), isnormal(), and signbit(). These macros are compatible with
the isinf(), isnormal(), and signbit() functions except that they may
return any non-zero value, not necessarily 1, when the corresponding
condition is met. In a source file that includes <math.h>, references
to isinf(), isnormal(), and signbit() result in substituton of these
macros by default. In order to invoke the actual isinf(), isnormal(),
and signbit() functions, a source file must either not include <math.h>
or else explicitly undefine the corresponding macros. Unlike the
isinf(), isnormal(), and signbit() functions, which only accept argu‐
ments of type double, however, the macros are type-generic; i.e., their
arguments may be any expression of type float, double, or long double.
Therefore, undefining the macros may change the behavior of a program
that uses them with arguments of type other than double. Such a pro‐
gram must also be changed to use the functions of the corresponding
types, e.g., isinff(), isinfl(), etc. See isinf(3M), isnormal(3M), and
signbit(3M) for more information.
14 Mar 2009 ieee_sun(3M)