VMS Help  —  CRTL  frexp
    Calculates the fractional and exponent parts of a floating-point
    value.

    Format

      #include  <math.h>

      double frexp  (double value, int *eptr);

      float frexpf  (float value, int *eptr);
                    (Integrity servers, Alpha)

      long double frexpl (long double value, int *eptr);
                          (Integrity servers, Alpha)

1  –  Arguments

 value

    A floating-point number of type double, float, or long double.

 eptr

    A pointer to an int where frexp places the exponent.

2  –  Description

    The frexp functions break the floating-point number (value) into
    a normalized fraction and an integral power of 2, as follows:

    value = fraction * (2exp)

    The fractional part is returned as the return value. The exponent
    is placed in the integer variable pointed to by eptr.

3  –  Example

        #include <math.h>

        main ()
        {
           double val = 16.0, fraction;
           int exp;

           fraction = frexp(val, &exp);
           printf("fraction = %f\n",fraction);
           printf("exp = %d\n",exp);

        }

      In this example, frexp converts the value 16 to .5 * 2 . The

      example produces the following output:

        fraction = 0.500000
        exp = 5

      |value| = Infinity or NaN is an invalid argument.

4  –  Return Values

    x                  The fractional part of value.
    0                  Both parts of the result are 0.
    NaN                If value is NaN, NaN is returned, errno
                       is set to EDOM, and the value of *eptr is
                       unspecified.
    value              If |value| = Infinity, value is returned,
                       errno is set to EDOM, and the value of *eptr
                       is unspecified.
Close Help