Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

abs(3)

ieee(3M)

math(3M)



FLOOR(3M)           RISC/os Reference Manual            FLOOR(3M)



NAME
     fabs, floor, ceil, rint - absolute value, floor, ceiling,
          and round-to-nearest functions

SYNOPSIS
     #include <math.h>

     double floor(x)
     double x;

     float ffloor(float x)
     float x;

     double ceil(x)
     double x;

     float fceil(float x)
     float x;

     double trunc(x)
     double x;

     float ftrunc(float x)
     float x;

     double fabs(x)
     double x;

     double rint(x)
     double x;

     double fmod (x, y)
     double x, y;

DESCRIPTION
     floor
      and ffloor return the largest integer no greater than x for
     double and float data types respectively.

     ceil and fceil return the smallest integer no less than x
     for double and float data types respectively.

     trunc and ftrunc return the integer (represented as a
     floating-point number) of x with the fractional bits trun-
     cated for double and float data types respectively.

     fabs returns the absolute value |x|.

     rint returns the integer (represented as a double precision
     number) nearest x in the direction of the prevailing round-
     ing mode.




                        Printed 11/19/92                   Page 1





FLOOR(3M)           RISC/os Reference Manual            FLOOR(3M)



     fmod returns the floating-point remainder of the division of
     x by y:  zero if y is zero or if x/y would overflow; other-
     wise the number f with the same sign as x, such that x = iy
     + f for some integer i, and |f| < |y|.

NOTES
     In the default rounding mode, to nearest, rint(x) is the
     integer nearest x with the additional stipulation that if
     |rint(x)-x|=1/2 then rint(x) is even.  Other rounding modes
     can make rint act like floor, or like ceil, or round towards
     zero.

     Another way to obtain an integer near x is to declare (in C)

          double x;     int k;    k = x;

     The MIPS C compiler rounds x towards 0 to get the integer k.
     Also note that, if x is larger than k can accommodate, the
     value of k and the presence or absence of an integer over-
     flow are hard to predict.

     The routine fabs is in libc.a rather than libm.a.

SEE ALSO
     abs(3), ieee(3M), math(3M).






























 Page 2                 Printed 11/19/92



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