Chapter Contents |
Previous |
Next |
fmod |
Portability: | ISO/ANSI C conforming, UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
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 pennies\n", leftovers); }
RELATED FUNCTIONS |
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.