5 * Floating point numeric utilities
11 * double ceil(), floor(), frexp(), ldexp();
12 * int signbit(), isnan(), isfinite();
18 * y = frexp( x, &expnt );
28 * All four routines return a double precision floating point
31 * floor() returns the largest integer less than or equal to x.
32 * It truncates toward minus infinity.
34 * ceil() returns the smallest integer greater than or equal
35 * to x. It truncates toward plus infinity.
37 * frexp() extracts the exponent from x. It returns an integer
38 * power of two to expnt and the significand between 0.5 and 1
39 * to y. Thus x = y * 2**expn.
41 * ldexp() multiplies x by 2**n.
43 * signbit(x) returns 1 if the sign bit of x is 1, else 0.
45 * These functions are part of the standard C run time library
46 * for many but not all C compilers. The ones supplied are
47 * written in C for either DEC or IEEE arithmetic. They should
48 * be used only if your compiler library does not already have
51 * The IEEE versions assume that denormal numbers are implemented
52 * in the arithmetic. Some modifications will be required if
53 * the arithmetic has abrupt rather than gradual underflow.
58 Cephes Math Library Release 2.3: March, 1995
59 Copyright 1984, 1995 by Stephen L. Moshier
66 /* ceil(), floor(), frexp(), ldexp() may need to be rewritten. */
76 /* Return 1 if the sign bit of x is 1, else 0. */
90 if( sizeof(int) == 4 )
105 return( u.s[3] < 0 );
108 return( u.s[3] < 0 );
111 return( u.s[0] < 0 );
117 /* Return 1 if x is a number that is Not a Number, else return 0. */
132 if( sizeof(int) == 4 )
135 if( ((u.i[1] & 0x7ff00000) == 0x7ff00000)
136 && (((u.i[1] & 0x000fffff) != 0) || (u.i[0] != 0)))
140 if( (u.s[1] & 0x7fff) == 0)
142 if( (u.s[2] | u.s[1] | u.s[0]) != 0 )
147 if( ((u.i[0] & 0x7ff00000) == 0x7ff00000)
148 && (((u.i[0] & 0x000fffff) != 0) || (u.i[1] != 0)))
154 { /* size int not 4 */
156 if( (u.s[3] & 0x7ff0) == 0x7ff0)
158 if( ((u.s[3] & 0x000f) | u.s[2] | u.s[1] | u.s[0]) != 0 )
163 if( (u.s[3] & 0x7fff) == 0)
165 if( (u.s[2] | u.s[1] | u.s[0]) != 0 )
170 if( (u.s[0] & 0x7ff0) == 0x7ff0)
172 if( ((u.s[0] & 0x000f) | u.s[1] | u.s[2] | u.s[3]) != 0 )
177 } /* size int not 4 */
186 /* Return 1 if x is not infinite and is not a NaN. */
201 if( sizeof(int) == 4 )
204 if( (u.i[1] & 0x7ff00000) != 0x7ff00000)
208 if( (u.s[3] & 0x7fff) != 0)
212 if( (u.i[0] & 0x7ff00000) != 0x7ff00000)
220 if( (u.s[3] & 0x7ff0) != 0x7ff0)
224 if( (u.s[3] & 0x7fff) != 0)
228 if( (u.s[0] & 0x7ff0) != 0x7ff0)