1 /* s_rintl.c -- long double version of s_rint.c.
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 * Developed at SunPro, a Sun Microsystems, Inc. business.
9 * Permission to use, copy, modify, and distribute this
10 * software is freely granted, provided that this notice
12 * ====================================================
15 #if defined (LIBM_SCCS) && ! defined (lint)
16 static char rcsid
[] = "$NetBSD: $";
21 * Return x rounded to integral value according to the prevailing
24 * Using floating addition.
26 * Inexact flag raised if x not equal to rintl(x).
29 #define NO_MATH_REDIRECT
31 #include <math_private.h>
32 #include <libm-alias-ldouble.h>
33 #include <math-use-builtins.h>
39 return __builtin_rintl (x
);
41 /* Use generic implementation. */
42 static const _Float128
44 5.19229685853482762853049632922009600E+33L, /* 0x406F000000000000, 0 */
45 -5.19229685853482762853049632922009600E+33L /* 0xC06F000000000000, 0 */
48 uint64_t i1
__attribute__ ((unused
));
50 GET_LDOUBLE_WORDS64 (i0
, i1
, x
);
51 sx
= (((uint64_t) i0
) >> 63);
52 j0
= ((i0
>> 48) & 0x7fff) - 0x3fff;
59 GET_LDOUBLE_MSW64 (i0
, t
);
60 SET_LDOUBLE_MSW64 (t
, (i0
& 0x7fffffffffffffffLL
) | (sx
<< 63));
67 return x
+ x
; /* inf or NaN */
69 return x
; /* x is integral */
72 return w
- TWO112
[sx
];
73 #endif /* ! USE_RINTL_BUILTIN */
75 libm_alias_ldouble (__rint
, rint
)