ceil(3C)
_________________________________________________________________
ceil function
Return the ceiling of a number.
_________________________________________________________________
Calling Sequence
double m, n, ceil();
m = ceil(n);
where m and n are of type double.
Description
The ceil function returns the ceiling of the number you pass to
it. The ceiling of a floating-point number f.p is f+1 if p > 0,
and f otherwise.
The include file math.h defines this function.
This function does not check for type double.
Returns
The ceil function returns the ceiling of n.
Related Functions
See also the floor, fmax, and fmin functions.
Example
/* Program test for the ceil() function */
#include <stdio.h>
#include <math.h>
double m, n, atof(), ceil();
int i = 1;
main(argc, argv)
int argc;
char *argv[];
{
while (i < argc) {
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
ceil(3C)
n = atof(argv[i]);
printf("The ceiling of %f is %f.\n", n, m = ceil(n));
i++;
}
}
If you call the program test with the input numbers
34.5
3.14159
9.0
.0001
you get the output
The ceiling of 34.500000 is 35.000000.
The ceiling of 3.141590 is 4.000000.
The ceiling of 9.000000 is 9.000000.
The ceiling of 0.000100 is 1.000000.
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)