frexp(3) Library Functions Manual frexp(3)
NAME
frexp, ldexp, logb, scalb - Manipulate floating-point numbers
LIBRARY
Math Library (libm.a)
SYNOPSIS
#include <math.h>
double frexp (double x, int *n); float frexpf (float x, int *n);
double ldexp (double y, int n); float ldexpf (float y, int n); dou-
ble logb (double x); float logbf (float x); double scalb (double
x, double n); float scalbf (float x, float n);
STANDARDS
Interfaces documented on this reference page conform to industry stan-
dards as follows:
frexp(): XPG4
ldexp(): XPG4
logb(): XPG4-UNIX
scalb(): XPG4-UNIX
Refer to the standards(5) reference page for more information about in-
dustry standards and associated tags.
DESCRIPTION
Every nonzero number can be written uniquely as the normalized mantissa
(fraction) z times 2 raised to the power p, where the absolute value of
z is in the range [0.5, 1.0), and the exponent p, is an integer.
The frexp() and frexpf() functions break a floating-point number into a
normalized fraction and an integral power of 2. The functions store the
integer in the int object pointed to by the n parameter and return the
fraction part.
The ldexp() and ldexpf() functions multiply a floating-point number, y,
by an integral power of 2.
The logb() and logbf() functions return a signed integer converted to
double-precision floating-point and so chosen that 1 <= |x|/2**n < 2
unless x = 0 or |x| = infinity or x lies between 0 and the Underflow
Threshold.
IEEE 754 defines logb(+infinity) = +infinity and logb(0) = -infinity.
The latter is required to signal Division-by-Zero.
The scalb() and scalbf() functions are defined as x*(2**n) for integer
n.
The following table describes function behavior in response to excep-
tional arguments:
tab(@); lfHB lfHB lfHB l l l . _
Function@Exceptional Argument@Routine Behavior
_
frexp(), frexpf()@|x| = infinity@Invalid argument
logb(), logbf()@|x| = infinity@Invalid argument
scalb(), scalbf()@x*(2**n) > max_float@Overflow
scalb(), scalbf()@x*(2**n) < min_float@Underflow
ldexp(), ldexpf()@x*(2**n) > max_float@Overflow
ldexp(), ldexpf()@x*(2**n) < min_float@Underflow
_
The following table lists boundary values used by these functions:
tab(@); lfHB lfHB lfHB lfHB l l l lw(1.5i). _
Value Name@Data Type@Hexadecimal Value@Decimal Value
_
max_float@S_FLOAT@
[email protected]
@T_FLOAT@
[email protected]
min_float@S_FLOAT@
[email protected]
@T_FLOAT@
[email protected]
_ delim off
frexp(3)