Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>fmod() calculate floating-point remainder</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fmod()                  Calculate Floating-Point Remainder

 #include   <math.h>                     Required for declarations only

 double     fmod(x,y);
 double     x;                           Floating-point dividend
 double     y;                           Floating-point divisor

    fmod() returns the remainder of 'x'/'y'.  The remainder (r) will have
    the same sign as 'x'; the absolute value of (r) will be less than the
    absolute value of 'y'; and the following equation will be true:

                        (x == i * y + r)

    where (i) is a signed integer and (r) is the value returned by
    fmod().

       Returns:     Remainder of 'x'/'y'.  If 'y' is 0.0 then 0.0 is
                    returned.

   -------------------------------- Example ---------------------------------

    The following statements calculate the floating point remainders of
    -15.0 / 4.0, 6.1 / -2.5 and 5.5 / 0.0:

           #include <math.h>      /* Required for function definition only */

           main()
           {
               double x, y, z;

               x = fmod(-15.0, 4.0);   /* x = -3.0 */
               y = fmod(6.1, -2.5);    /* y =  1.1 */
               z = fmod(5.5, 0.0);     /* z =  0.0 */
           }


See Also: ceil() fabs() floor()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson