Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

matherr(3M)

ieee_functions(3M)

NAME

ieee_functions, ilogb, isnan, copysign, fabs, fmod, nextafter, remainder, scalbn − appendix and related miscellaneous functions for IEEE arithmetic

SYNOPSIS

#include <math.h>

int ilogb(double x);

int isnan(double x);

double copysign(double x, double y);

double fabs(double x);

double fmod(double x, double y);

double nextafter(double x, double y);

double remainder(double x, double y);

double scalbn(double x, int n);

MT-LEVEL

MT-Safe with exceptions

DESCRIPTION

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

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. 

isnan(x) returns 1 if x is NaN; otherwise it returns 0. 

copysign(x,y) returns a value with the magnitude of x and with the sign bit of y.

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, the largest int defined in <values.h> 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 cannot 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, ∞, and NaN. 

RETURN VALUES

For exceptional cases, matherr(3M) tabulates the values to be returned as dictated by various Standards. 

SEE ALSO

matherr(3M)

NOTES

These functions are MT-Safe when compiled with the shared library, libm.so, but are unsafe if compiled with the archived library libm.a. 

SunOS 5.2  —  Last change: 5 Mar 1993

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026