* The following bugs are resolved with this release:
887, 2542, 2543, 2558, 2898, 4404, 6803, 10432, 14341, 14912, 15367,
- 15384, 15470, 15786, 15918, 16141, 16296, 16347, 16399, 16415, 16517,
- 16519, 16520, 16521, 16620, 16734, 16973, 16985, 17118, 17243, 17244,
- 17250, 17441, 17787, 17886, 17887, 17905, 18084, 18086, 18240, 18265,
- 18370, 18421, 18480, 18525, 18595, 18589, 18610, 18618, 18647, 18661,
- 18674, 18675, 18681, 18724, 18757, 18778, 18781, 18787, 18789, 18790,
- 18795, 18796, 18803, 18820, 18823, 18824, 18825, 18857, 18863, 18870,
- 18872, 18873, 18875, 18887, 18921, 18951, 18952, 18956, 18961, 18966,
- 18967, 18969, 18970, 18977, 18980, 18981, 18985, 19003, 19012, 19016,
- 19018, 19032, 19046, 19049, 19050, 19059, 19071, 19076, 19077, 19078,
- 19079, 19085, 19086, 19088, 19094, 19095.
+ 15384, 15470, 15786, 15918, 16141, 16296, 16347, 16399, 16415, 16422,
+ 16517, 16519, 16520, 16521, 16620, 16734, 16973, 16985, 17118, 17243,
+ 17244, 17250, 17441, 17787, 17886, 17887, 17905, 18084, 18086, 18240,
+ 18265, 18370, 18421, 18480, 18525, 18595, 18589, 18610, 18618, 18647,
+ 18661, 18674, 18675, 18681, 18724, 18757, 18778, 18781, 18787, 18789,
+ 18790, 18795, 18796, 18803, 18820, 18823, 18824, 18825, 18857, 18863,
+ 18870, 18872, 18873, 18875, 18887, 18921, 18951, 18952, 18956, 18961,
+ 18966, 18967, 18969, 18970, 18977, 18980, 18981, 18985, 19003, 19012,
+ 19016, 19018, 19032, 19046, 19049, 19050, 19059, 19071, 19076, 19077,
+ 19078, 19079, 19085, 19086, 19088, 19094, 19095.
* The obsolete header <regexp.h> has been removed. Programs that require
this header must be updated to use <regex.h> instead.
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <limits.h>
#include <math.h>
#include <math_ldbl_opt.h>
+#include <math_private.h>
+#include <stdint.h>
long long int
__llrint (double x)
{
- return (long long int) __rint (x);
+ double rx = __rint (x);
+ if (HAVE_PPC_FCTIDZ || rx != x)
+ return (long long int) rx;
+ else
+ {
+ /* Avoid incorrect exceptions from libgcc conversions (as of GCC
+ 5): <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59412>. */
+ if (fabs (rx) < 0x1p31)
+ return (long long int) (long int) rx;
+ uint64_t i0;
+ EXTRACT_WORDS64 (i0, rx);
+ int exponent = ((i0 >> 52) & 0x7ff) - 0x3ff;
+ if (exponent < 63)
+ {
+ unsigned long long int mant
+ = (i0 & ((1ULL << 52) - 1)) | (1ULL << 52);
+ if (exponent < 52)
+ mant >>= 52 - exponent;
+ else
+ mant <<= exponent - 52;
+ return (long long int) ((i0 & (1ULL << 63)) != 0 ? -mant : mant);
+ }
+ else if (rx == (double) LLONG_MIN)
+ return LLONG_MIN;
+ else
+ return (long long int) (long int) rx << 32;
+ }
}
weak_alias (__llrint, llrint)
#ifdef NO_LONG_DOUBLE