Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ldexp(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                ldexp(3C)



        _________________________________________________________________
        ldexp                                                    function
        Multiply a value by 2 to a specified power.
        _________________________________________________________________


        Calling Sequence

        #include <math.h>

        double ldexp(), mantissa, result;
        int exponent;
        result = ldexp(mantissa, exponent);



          where   result is the number resulting from raising 2 to the
                  exponent power and multiplying it by the mantissa.
                  mantissa is the double precision mantissa part.
                  exponent is the integer exponent power of 2.



        Description

        The ldexp function enables you to assemble a double-precision
        floating-point number from its mantissa (x) and exponent (n)
        parts such that the number is equal to x * 2**n.


        Returns

        The ldexp function returns the result of a mantissa multiplied by
        2**n.


        Related Functions

        See also the exp, pow, and frexp functions.


        Example

        /* Program test for the ldexp() function */

        #include <stdio.h>

        double  ldexp(), x, mantissa;
        int     exponent, i = 1;

        main(argc, argv)



        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                                ldexp(3C)



        int argc;
        char *argv[];
        {
            while (i + 1 < argc) {
                mantissa = atof(argv[i]);
                exponent = atoi(argv[i + 1]);
                x = ldexp(mantissa, exponent);
                printf("Ldexp(%g, %d) = %g\n", mantissa, exponent, x);
                i += 2;
            }
        }

        For the input values of 0.5, 1, 0.5, 2, -0.75, 2, 0.5, and -3,
        the following results are produced:

        Ldexp(0.5, 1) = 1
        Ldexp(0.5, 2) = 2
        Ldexp(-0.75, 2) = -3
        Ldexp(0.5, -3) = 0.0625



































        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026