Chapter Contents |
Previous |
Next |
floor |
Portability: | ISO/ANSI C conforming, UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
IMPLEMENTATION | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
SYNOPSIS |
#include <math.h> double floor(double y);
DESCRIPTION |
floor
rounds a real number down to the next smaller integral real number.
RETURN VALUE |
floor
accepts a floating-point argument
y
and
rounds it down to the next smaller integer expressed as a floating-point number.
IMPLEMENTATION |
floor
is implemented as a built-in function unless it is undefined by an
#undef
statement.
EXAMPLE |
#include <math.h> #include <stdio.h> int moda, modb, df; double score, rank; main() { puts("Enter two integers: "); scanf("%d %d", &moda, &modb); puts("Enter an integer divisor: "); scanf("%d",&df); /* Add the two numbers, divide by the given divisor, */ /* and then round up to the closest integer less */ /* than the result. */ score = ( moda + modb); score /= df; rank = floor(score); /* Print the rounded result (its "floor"ed value). */ printf("The floor of (%d + %d)/ %d = %f\n",moda,modb,df,rank); }
RELATED FUNCTIONS |
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.