floor(3C)
_________________________________________________________________
floor function
Determine the floor of a number.
_________________________________________________________________
Calling Sequence
double m, n, floor();
m = floor(n);
where m and n are of type double.
Description
The floor function returns the floor of the number you pass to
it. The floor is the largest integer not greater than the number
itself. The floor of a positive floating-point number f.p is f,
and the floor of a negative floating-point number -f.p is -(f+1).
Returns
The floor function returns the floor of a given number.
Related Functions
See also the ceil, fmin, and min functions.
Example
/* program test for the floor() function */
#include <stdio.h>
#include <math.h>
int i = 1;
double m, n, atof(), floor();
main(argc, argv)
int argc;
char *argv[];
{
while (i < argc) {
m = atof(argv[i]);
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
floor(3C)
printf("Floor of %f = %f\n", m, n = floor(m));
i++;
}
}
A call to the program test with the input numbers
4.5
4.0
-3.5
.007e2
generates the output
Floor of 4.500000 = 4.000000
Floor of 4.000000 = 4.000000
Floor of -3.500000 = -4.000000
Floor of 0.700000 = 0.000000
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)