Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fmod(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                 fmod(3C)



        _________________________________________________________________
        fmod                                                     function
        Return the modulus of two arguments.
        _________________________________________________________________


        Calling Sequence

        double x, y, z, fmod();
        y = fmod(x,z);

        where x, y, and z are of type double.


        Description

        Use the fmod function to find the modulus of two numbers.  The
        modulus is the remainder when one number is divided by another.
        With fmod, y receives the remainder when x is divided by z.

        The include file math.h defines this function.


        Returns

        The fmod function returns the remainder of the two numbers you
        pass.  If an error occurs, fmod returns the first argument.


        Related Functions

        See also the modf function.


        Example

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

        #include <stdio.h>
        #include <math.h>

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

        main(argc, argv)
        int     argc;
        char   *argv[];
        {
            while (i+1 < argc) {
                m = atof(argv[i]);
                n = atof(argv[i+1]);



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





                                                                 fmod(3C)



                printf("fmod of %f and %f = %f\n", m, n, o = fmod(m, n));
                i++;
            }
        }

        A call to the program test with the input numbers

        21
        13
        8
        5
        3

        generates the output

        fmod of 21.000000 and 13.000000 = 8.000000
        fmod of 13.000000 and 8.000000 = 5.000000
        fmod of 8.000000 and 5.000000 = 3.000000
        fmod of 5.000000 and 3.000000 = 2.000000



































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



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