[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    floor(3M) manual page Table of Contents

Name

floor, ceil, rint - round to integral value in floating-point format

Synopsis

cc [ flag ... ] file ... -lm [ library ... ]

#include <math.h>

double ceil(double x);

double floor(double x);

double rint(double x);

MT-Level

MT-Safe

Description

ceil(), floor() and rint() convert a double value into an integral value in double format. They vary in how they choose the result when the argument is not already an integral value. Here an ‘integral value’ means a value of a mathematical integer, which however might be too large to fit in a particular computer’s int format. All sufficiently large values in a particular floating-point format are already integral; in IEEE754 double-precision format, that means all values >= 2**52. Zeros, infinities, and quiet NaNs are treated as integral values by these functions, which always preserve their argument’s sign.

ceil() returns the least integral value greater than or equal to x. This corresponds to IEEE754 rounding toward positive infinity.

floor() returns the greatest integral value less than or equal to x. This corresponds to IEEE754 rounding toward negative infinity.

rint() rounds x to an integral value according to the current IEEE754 rounding direction.


Table of Contents