18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 */
25 /*
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29
30 /*
31 * ceill(x) return the biggest integral value below x
32 * floorl(x) return the least integral value above x
33 *
34 * NOTE: aintl(x), anintl(x), ceill(x), floorl(x), and rintl(x) return result
35 * with the same sign as x's, including 0.0.
36 */
37
38 #pragma weak ceill = __ceill
39 #pragma weak floorl = __floorl
40
41 #include "libm.h"
42 #include "longdouble.h"
43
44 static const long double qone = 1.0L;
45
46 long double
47 ceill(long double x) {
48 long double t;
49
50 if (!finitel(x))
51 return (x + x);
52 t = rintl(x);
53 if (t >= x) /* already ceil(x) */
54 return (t);
55 else /* t < x case: return t+1 */
56 return (copysignl(t + qone, x));
57 }
58
59 long double
|
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 */
25 /*
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29
30 /*
31 * ceill(x) return the biggest integral value below x
32 * floorl(x) return the least integral value above x
33 *
34 * NOTE: aintl(x), anintl(x), ceill(x), floorl(x), and rintl(x) return result
35 * with the same sign as x's, including 0.0.
36 */
37
38 #pragma weak __ceill = ceill
39 #pragma weak __floorl = floorl
40
41 #include "libm.h"
42 #include "longdouble.h"
43
44 static const long double qone = 1.0L;
45
46 long double
47 ceill(long double x) {
48 long double t;
49
50 if (!finitel(x))
51 return (x + x);
52 t = rintl(x);
53 if (t >= x) /* already ceil(x) */
54 return (t);
55 else /* t < x case: return t+1 */
56 return (copysignl(t + qone, x));
57 }
58
59 long double
|