HP 3000 Manuals

frexp [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation


HP C/iX Library Reference Manual

frexp 

Breaks a floating-point number into a normalized fraction and an integral
power of 2.

Syntax 

     #include <math.h>
     double frexp (double value, int *eptr);

Parameters 

value         A real number input to the function.

eptr          A pointer to the integer exponent returned by the function.

Return Values 

x             A real number between 0.5 and 1.

Description 

The frexp function accepts a double value, and returns two values, x and
n, such that

     value == x * 2n 

where x is a double quantity in the range 0.5 < x < 1, and n is an
integer exponent.  In the frexp function, value is the value to be
processed, and eptr is a pointer to an integer variable where the
exponent n is to be stored.  The quantity x is the return value of frexp.

Example 

The following program accepts a number argument and uses frexp to output
that number's representation in the form shown above:

        main(argc, argv)
        int argc;
        char *argv[ ];
        {
           double value, x, frexp();
           int eptr;
           sscanf(argv[1], "%lf", &value);
           x = frexp(value, &eptr);
           printf("%g = %g * 2^%d\n", value, x, eptr);
        }

See Also 

ldexp(), modf(), ANSI C 4.5.4.2, POSIX.1 8.1



MPE/iX 5.0 Documentation