fmod -- Floating-Point Conversion: Modulus


SYNOPSIS
#include <math.h>
double fmod(double y, double z);
DESCRIPTION
fmod
determines the remainder when a real value y
is divided by
a real value z
to produce an integer i
. This function satisfies
these relationships:
result x
y = i * z + x, |x| < |y|
This function performs the same operation for double
arguments as the
%
operator does for int
arguments.
RETURN VALUE
fmod
returns the remainder of the division. If z
is 0, the value
returned is 0. Otherwise, the returned value has the same sign as y
and
is less than z
.
EXAMPLE
#include <math.h>
#include <stdio.h>
main()
{
float dollars;
float leftovers;
puts("Enter number of dollars");
scanf("%f", &dollars);
leftovers = fmod(dollars, .05);
printf("$ %.2f contains at least ", dollars);
printf(" %.2f in penniesn", leftovers);
}
RELATED FUNCTIONS
modf
SEE ALSO
Mathematical Functions