Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dg_rand1(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                             dgrand1(3C)



        _________________________________________________________________
        dgrand1                                                 function
        Generate and return a random number in the range 0 to 1.
        _________________________________________________________________


        Calling Sequence

        double m, dgrand1();
        m = dgrand1();

        where m is of type double.


        Description

        The dg_rand1 function generates and returns to your program a
        random number in the range 0 to 1.  The seed (number from which
        to start the random number generation) is +1, unless you change
        it with the dg_srand function.

        The include file math.h defines this entry.


        Returns

        The return value is 0.0 <= m < 1.0 .


        Related Functions

        See also the dg_rand and dg_srand functions.


        Example

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

        #include <math.h>

        int  i, c;
        double  result, dg_rand1();

        main(argc, argv)
        int    argc;
        char  *argv[];
        {
            c = atoi(argv[1]);
            printf("List of %d random numbers:\n\n", c);
            for (i = 1; i <= c; i++)
                printf("%f\n", result = dg_rand1());



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





                                                             dgrand1(3C)



        }

        A call to the program test with an argument of 4 generates the
        output

        List of 4 random numbers:

        0.242561
        0.546138
        0.541656
        0.836353

        These numbers will vary.









































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



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