IEEE_FUNCTIONS(3M)

NAME
ieee_functions, fp_class, finite, ilogb, isinf, isnan, isnormal, issubnormal, iszero, signbit, copysign, fabs, fmod, nextafter, remainder, scalbn - appendix and related miscellaneous functions for IEEE arithmetic

SYNOPSIS
#include <math.h>
#include <stdio.h>

enum fp_class_type fp_class(x)
double x;

int finite(x)
double x;

int ilogb(x)
double x;

int isinf(x)
double x;

int isnan(x)
double x;

int isnormal(x)
double x;

int issubnormal(x)
double x;

int iszero(x)
double x;

int signbit(x)
double x;

void ieee_retrospective(f)
FILE *f;

void nonstandard_arithmetic()

void standard_arithmetic()

double copysign(x,y)
double x, y;

double fabs(x)
double x;

double fmod(x,y)
double x, y;

double nextafter(x,y)
double x, y;

double remainder(x,y)
double x, y;

double scalbn(x,n)
double x; int n;

DESCRIPTION

Most of these functions provide capabilities required by ANSI/IEEE Std 754-1985 or suggested in its appendix.

fp_class(x) corresponds to the IEEE's class() and classifies x as zero, subnormal, normal, ∞, or quiet or signaling NaN. <floatingpoint.h> defines enum fp_class_type. The following functions return 0 if the indicated condition is not satisfied:

    finite(x)
        returns 1 if x is zero, subnormal or normal
    isinf(x)
        returns 1 if x is ∞
    isnan(x)
        returns 1 if x is NaN
    isnormal(x)
        returns 1 if x is normal
    issubnormal(x)
        returns 1 if x is subnormal
    iszero(x)
        returns 1 if x is zero
    signbit(x)
        returns 1 if x's sign bit is set

ilogb(x) returns the unbiased exponent of x in integer format. ilogb(±∞) = +MAXINT and ilogb(0) = -MAXINT; <values.h> defines MAXINT as the largest int. ilogb(x) never generates an exception. When x is subnormal, ilogb(x) returns an exponent computed as if x were first normalized.

ieee_retrospective(f) prints a message to the FILE f listing all IEEE accrued exception-occurred bits currently on, unless no such bits are on or the only one on is "inexact". It's intended to be used at the end of a program to indicate whether some IEEE floating-point exceptions occurred that might have affected the result.

standard_arithmetic() and nonstandard_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.

copysign(x,y) returns x with y's sign bit.

fabs(x) returns the absolute value of x.

nextafter(x,y) returns the next machine representable number from x in the direction y.

remainder(x, y) and fmod(x, y) return a remainder of x with respect to y; that is, the result r is one of the numbers that differ from x by an integral multiple of y. Thus (x - r)/y is an integral value, even though it might exceed MAXINT if it were explicitly computed as an int. Both functions return one of the two such r smallest in magnitude. remainder(x, y) is the operation specified in ANSI/IEEE Std 754-1985; the result of fmod(x, y) may differ from remainder()'s result by ±y. The magnitude of remainder's result can not exceed half that of y; its sign might not agree with either x or y. The magnitude of fmod()'s result is less than that of y; its sign agrees with that of x. Neither function can generate an exception as long as both arguments are normal or subnormal. remainder(x, 0) , fmod(x, 0) , remainder(∞, y) , and fmod(∞, y) are invalid operations that produce a NaN.

scalbn(x, n) returns x* 2**n computed by exponent manipulation rather than by actually performing an exponentiation or a multiplication. Thus

    1 ≤ scalbn(fabs(x),-ilogb(x)) < 2

for every x except 0, infinity, and NaN.

SEE ALSO
floatingpoint(3), ieee_flags(3M), matherr(3M)