Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

floor(3M)

NAME

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

SYNOPSIS

#include <math.h>

double ceil(double x);

double floor(double x);

double rint(double x);

MT-LEVEL

MT-Safe with exceptions

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. 

NOTES

These functions are MT-Safe when compiled with the shared library, libm.so, but are unsafe if compiled with the archived library libm.a. 

Sun Microsystems  —  Last change: 5 Mar 1993

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026