Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sqrt(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                 sqrt(3C)



        _________________________________________________________________
        sqrt                                            $builtin function
        Return the square root of a number.
        _________________________________________________________________


        Calling Sequence

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

        (or)

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

        where m and n are of type double.


        Description

        The sqrt function returns the square root of the number you pass
        to it.

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


        Returns

        If this routine receives an illegal input, it returns 0.0 and
        sets errno to EDOM (defined in errno.h).


        Related Functions

        See also the other math functions.


        Example

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

        #include <math.h>

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




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





                                                                 sqrt(3C)



        main(argc, argv)

        int    argc;
        char  *argv[];
        {
            while (i < argc) {
                n = atof(argv[i]);
                printf("Square root of %lf = %lf.\n",
                       n, m = sqrt(n));
                i++;
            }
        }

        A call to the program test with

        x test [inputnos]

        where the file input_nos contains

        3.1416 &
        2.7182 &
        1.4142 &
        0.0009

        generates the output

        Square root of 3.141600 = 1.772455.
        Square root of 2.718200 = 1.648696.
        Square root of 1.414200 = 1.189201.
        Square root of 0.000900 = 0.030000.
























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



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