File: libc.info,  Node: Normalization Functions,  Next: Rounding Functions,  Pr\ev: Absolute Value,  Up: Arithmetic Functions

Normalization Functions
-----------------------

   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
*Note Floating Point 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'.

 - Function: double frexp (double VALUE, int *EXPONENT)
 - Function: float frexpf (float VALUE, int *EXPONENT)
 - Function: long double frexpl (long double VALUE, int *EXPONENT)
     These functions are used to split the number VALUE into a
     normalized fraction and an exponent.

     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'.

 - Function: double ldexp (double VALUE, int EXPONENT)
 - Function: float ldexpf (float VALUE, int EXPONENT)
 - Function: long double ldexpl (long double VALUE, int EXPONENT)
     These functions return the result of multiplying the floating-point
     number VALUE by 2 raised to the power EXPONENT.  (It can be used
     to reassemble floating-point numbers that were taken apart by
     `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'.

 - Function: double logb (double X)
 - Function: float logbf (float X)
 - Function: long double logbl (long double X)
     These functions return the integer part of the base-2 logarithm of
     X, an integer value represented in type `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'.

 - Function: double scalb (double VALUE, int EXPONENT)
 - Function: float scalbf (float VALUE, int EXPONENT)
 - Function: long double scalbl (long double VALUE, int EXPONENT)
     The `scalb' function is the BSD name for `ldexp'.

 - Function: long long int scalbn (double X, int n)
 - Function: long long int scalbnf (float X, int n)
 - Function: long long int scalbnl (long double X, int n)
     `scalbn' is identical to `scalb', except that the exponent N is an
     `int' instead of a floating-point number.

 - Function: long long int scalbln (double X, long int n)
 - Function: long long int scalblnf (float X, long int n)
 - Function: long long int scalblnl (long double X, long int n)
     `scalbln' is identical to `scalb', except that the exponent N is a
     `long int' instead of a floating-point number.

 - Function: long long int significand (double X)
 - Function: long long int significandf (float X)
 - Function: long long int significandl (long double X)
     `significand' returns the mantissa of X scaled to the range [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.



