The functions described in this section are primarily provided as a way to efficiently perform certain low-level manipulations on floating point numbers that are represented internally using a binary radix; see section Floating Point Representation Concepts. These functions are required to have equivalent behavior even if the representation does not use a radix of 2, but of course they are unlikely to be particularly efficient in those cases.
All these functions are declared in `math.h'.
If the argument value is not zero, the return value is value
times a power of two, and is always in the range 1/2 (inclusive) to 1
(exclusive). The corresponding exponent is stored in
*exponent; the return value multiplied by 2 raised to this
exponent equals the original number value.
For example, frexp (12.8, &exponent) returns 0.8 and
stores 4 in exponent.
If value is zero, then the return value is zero and
zero is stored in *exponent.
frexp.)
For example, ldexp (0.8, 4) returns 12.8.
The following functions, which come from BSD, provide facilities
equivalent to those of ldexp and frexp.
double. This is
the highest integer power of 2 contained in x. The sign of
x is ignored. For example, logb (3.5) is 1.0 and
logb (4.0) is 2.0.
When 2 raised to this power is divided into x, it gives a
quotient between 1 (inclusive) and 2 (exclusive).
If x is zero, the return value is minus infinity if the machine supports infinities, and a very small number if it does not. If x is infinity, the return value is infinity.
For finite x, the value returned by logb is one less than
the value that frexp would store into *exponent.
scalb function is the BSD name for ldexp.
scalbn is identical to scalb, except that the exponent
n is an int instead of a floating-point number.
scalbln is identical to scalb, except that the exponent
n is a long int instead of a floating-point number.
significand returns the mantissa of x scaled to the range
@math{[1, 2)}.
It is equivalent to scalb (x, (double) -ilogb (x)).
This function exists mainly for use in certain standardized tests of IEEE 754 conformance.
Go to the first, previous, next, last section, table of contents.