Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ log(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                  log(3C)



        _________________________________________________________________
        log                                             $builtin function
        Determine the natural logarithm of a number.
        _________________________________________________________________


        Calling Sequence

        double m, n, log();
        m = log(n);

        (or)

        $builtin double log();
        double m, n;
        m = log(n);


        Description

        The log function returns the natural logarithm of a number. A
        natural log is a log to the base e; e has the approximate value
        2.718.

        The first version noted above uses a function call.  The second
        might generate smaller or faster code, but may not run under
        other C compilers.  The include file math.h defines this entry
        and uses the $builtin version.


        Returns

        If the log routine receives an illegal input (a zero or a
        negative number), it returns -HUGE (defined in math.h) and sets
        the last error (errno) to the error code ERANGE.  Otherwise, it
        returns the natural logarithm of the number passed to it.

        You can redefine the function matherr to provide alternate error
        handling.


        Related Functions

        See also the log10 function.


        Example

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

        #include <math.h>



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





                                                                  log(3C)



        double  atof(), m, n, log();
        int     i = 1;


        main(argc, argv)
        int     argc;
        char   *argv[];
        {
            while (i < argc) {
                n = atof(argv[i]);
                printf("Natural log of %f is %f.\n", n, m = log(n));
                i++;
            }
        }

        A call to the program test with the numbers 2, 2.718, 10, and
        1024 generates the output

        Natural log of 2.000000 is 0.693147.
        Natural log of 2.718000 is 0.999896.
        Natural log of 10.000000 is 2.302585.
        Natural log of 1024.000000 is 6.931472.
































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



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