Go to main content

man pages section 3: Extended Library Functions, Volume 4

Exit Print View

Updated: Thursday, June 13, 2019
 
 

signbit (3SUNMATH)

Name

fp_class, fp_classf, fp_classl, isinf, isinff, isinfl, isnormal, isnormalf, isnormall, issubnormal, issubnormalf, issubnormall, iszero, iszerof, iszerol, signbit, signbitf, signbitl, nonstandard_arithmetic, standard_arithmetic, ieee_retrospective - miscellaneous 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, normal, 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. Nonstandard 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. standard_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 precision 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. Fortran programs compiled with f95 in -f77 compatibility mode automatically call ieee_retrospective() before they exit. C/C++ programs and Fortran programs compiled with f95 in the default mode do not automatically 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(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
MT-Safe
Availability
system/library/math

See Also

copysign(3M), fex_set_log(3M), ilogb(3M), isfinite(3M), isinf(3SUNMATH), isnan(3M), isnormal(3SUNMATH), nextafter(3M), remainder(3M), scalbn(3M), signbit(3SUNMATH), attributes(7), floatingpoint.h(3HEAD)

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 arguments 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 program must also be changed to use the functions of the corresponding types, e.g., isinff(), isinfl(), etc. See isinf(3SUNMATH), isnormal(3SUNMATH), and signbit(3SUNMATH) for more information.