xref: /original-bsd/lib/libm/common_source/ieee.3 (revision 30ae0772)
IEEE 3M "8 May 1985"
C 4
NAME
copysign, drem, logb, scalb - copysign, remainder, exponent manipulations
SYNOPSIS
 #include <math.h> 

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

double drem(x, y) double x, y;

double logb(x) double x;

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

DESCRIPTION
These functions are necessary for, or recommended by the IEEE standard 754 for floating-point arithmetic.

Copysign(x,y) returns x with the sign of y.

Drem(x,y) returns r when y is not equal to 0; the remainder r is defined by the mathematical relation r=x-y*n where n is the integer nearest the exact value x/y; whenever |n-x/y|=1/2, then n is even. Thus, the remainder is always exact.

Logb(x) returns the exponent of x, a signed integer in double precision. When x is positive, the expression scalb(x,(int)(-logb(x))) lies strictly between 1 and 2; the expression equals 1 only if x is a power of 2.

Scalb(x,n) returns x*(2**n), x*2\u\s8n\s10\d, for integer values n without computing 2**n. 2\u\s8n\s10\d.

SEE ALSO
intro(3M)
DIAGNOSTICS
Drem(x,y) returns the reserved operand on the VAX when y is equal to 0. Logb(x) returns the hugest negative number on the VAX when x is equal to 0. If the correct value would overflow, scalb(x,n) returns the reserved operand on the VAX and sets errno to ERANGE.
AUTHOR
Kwok-Choi Ng
BUGS
Logb(0) should return -infinity.