Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ floor(3M) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

abs(3C)

matherr(3M)

math(5)

floor(3M)                                                         floor(3M)

NAME
     floor, floorf, ceil, ceilf, copysign, fmod, fmodf, fabs, fabsf, rint,
     remainder - floor, ceiling, remainder, absolute value functions

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

     #include <math.h>

     double floor(double x);

     float floorf(float x);

     double ceil(double x);

     float ceilf(float x);

     double copysign(double x, double y);

     double fmod(double x, double y);

     float fmodf(float x, float y);

     double fabs(double x);

     float fabsf(float x);

     double rint(double x);

     double remainder(double x, double y);

DESCRIPTION
     floor() and floorf() return the largest integer value (as a number of
     type double or float respectively) not greater than x.

     ceil() and ceilf() return the smallest integer of type double that is
     not less than x.

     copysign() returns x but with the sign of y.

     fmod() and fmodf() return the floating point remainder of the division
     of x by y. More precisely, they return the number f with the same sign
     as x, such that x = iy + f for some integer i, and |f| < |y|.

     fabs() and fabsf() return the absolute value of x, |x|.

     The rint() function returns the integral value (represented as a dou-
     ble) nearest x in the direction of the current rounding mode. The
     current rounding mode is implementation dependent. If the current
     rounding mode rounds toward negative infinity, then rint() is identi-
     cal to floor(). If the current rounding mode rounds toward positive
     infinity, then rint() is identical to ceil().



Page 1                       Reliant UNIX 5.44                Printed 11/98

floor(3M)                                                         floor(3M)

     remainder() returns the floating point remainder of the division of x
     by y. More precisely, it returns the value r = x - yn, where n is the
     integer nearest the exact value x/y. Whenever |n - x/y| = ½, then n is
     even.

RESULT
     floor() and ceil() return x when x is NaN, and errno is set to EDOM.
     If the correct value would cause overflow, floor() returns -HUGEVAL
     and ceil() returns HUGEVAL, and errno is set to ERANGE. If x is an
     infinite value or 0, the value of x is returned.

     fmod() and fmodf() return the respective argument when x or y is a
     NaN. If x is an infinite value or y is 0, NaN is returned and errno is
     set to EDOM. If x is 0 or y is an infinite value, the value of x is
     returned.

     fabs() and fabsf() return x if x is a NaN, and errno is set to EDOM.
     Upon successful completion, the rint() function returns the integer
     (represented as a double precision number) nearest x in the direction
     of the current rounding mode. When x is +Inf, rint() returns x. If the
     value of x is NaN, NaN is returned and errno may be set to EDOM.

     remainder() returns NaN when y is 0, and sets errno to EDOM.

ERRORS
     The following error code descriptions are function-specific. You will
     find a general description in introprm2(2) or in errno(5).

     The remainder() function will fail if:

     EDOM      The y argument is 0 or the x argument is positive or nega-
               tive infinity.

     The remainder() function may fail if:

     EDOM      The x or y argument is NaN.

     The rint() function may fail if:

     EDOM      The x argument is NaN.

NOTES
     The functions floorf(), ceilf(), fmodf(), and fabsf() can be used in
     ANSI mode only.

SEE ALSO
     abs(3C), matherr(3M), math(5).







Page 2                       Reliant UNIX 5.44                Printed 11/98

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