/* @(#)floor.c 4.2 9/11/85; 1.3 (ucb.elefunt) %G% */
* floor and ceil-- greatest integer <= arg
* algorithm for rint(x) in pseudo-pascal form ...
* ... delivers integer nearest x in direction of prevailing rounding
* const L = (last consecutive integer)/2
* = 2**52; for IEEE 754 Double
* if x != x then return x; ... NaN
* if |x| >= L then return x; ... already an integer
* t := x + s; ... = (x+s) rounded to integer
* Note: Inexact will be signaled if x is not an integer, as is
* customary for IEEE 754. No other signal can be emitted.
#if (defined(VAX)||defined(TAHOE))
static long Lx
[] = {0x5c00,0x0}; /* 2**55 */
static double L
= 4503599627370496.0E0
; /* 2**52 */
double s
,t
,one
= 1.0,copysign();
#if (!defined(VAX)&&!defined(TAHOE))
if (copysign(x
,one
) >= L
) /* already an integer */
t
= x
+ s
; /* x+s rounded to integer */