Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dg_rand(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                              dgrand(3C)



        _________________________________________________________________
        dgrand                                                  function
        Generate and return a random number in the range 0 to 32767.
        _________________________________________________________________


        Calling Sequence

        short int dgrand();
        int m;
        m = dgrand();

        where m is of type int.


        Description

        The dg_rand function generates and returns a random number; this
        function is Data General's version of the rand function. To be
        compatible with other C implementations, dg_rand returns a number
        in the range 0 to 32767.  The seed (number from which random
        number generation begins) is +1, unless you change it with the
        dg_srand function.

        The include file math.h defines this entry.


        Returns

        The dg_rand function returns the random number it generated.


        Related Functions

        See also the dg_rand1, rand, and dg_srand functions.


        Example

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

        #include <math.h>

        int  result, i, c;
        short int dg_rand();

        main(argc, argv)
        int    argc;
        char  *argv[];
        {
            c = atoi(argv[1]);



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





                                                              dgrand(3C)



            printf("List of %d random numbers:\n\n", c);
            for (i = 1; i<=c; i++)
                printf("%d\n", result = dg_rand());
        }

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

        List of 4 random numbers:

        30819
        12099
        10924
        22643

        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