*/
#include <math.h>
+#include <fix-int-fp-convert-zero.h>
#include <math_private.h>
#include <stdint.h>
#include <libm-alias-finite.h>
i = ((uint64_t) k & UINT64_C(0x8000000000000000)) >> 63;
hx = (hx & UINT64_C(0x000fffffffffffff)) | ((0x3ff - i) << 52);
y = (double) (k + i);
+ if (FIX_INT_FP_CONVERT_ZERO && y == 0.0)
+ y = 0.0;
INSERT_WORDS64 (x, hx);
z = y * log10_2lo + ivln10 * __ieee754_log (x);
return z + y * log10_2hi;
#include <math_private.h>
#include <libm-alias-double.h>
#include <stdint.h>
+#include <fix-int-fp-convert-zero.h>
double
__getpayload (const double *x)
|| (ix & 0xfffffffffffffULL) == 0)
return -1;
ix &= 0x7ffffffffffffULL;
+ if (FIX_INT_FP_CONVERT_ZERO && ix == 0)
+ return 0.0f;
return (double) ix;
}
libm_alias_double (__getpayload, getpayload)
#define lround __hidden_lround
#define __lround __hidden___lround
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <sysdep.h>
#include <math_private.h>
#include <libm-alias-double.h>
-
+#include <fix-fp-int-convert-overflow.h>
long long int
__llround (double x)
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+#ifdef FE_INVALID
+ /* The number is too large. Unless it rounds to LLONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+ if (FIX_DBL_LLONG_CONVERT_OVERFLOW && x != (double) LLONG_MIN)
+ {
+ feraiseexcept (FE_INVALID);
+ return sign == 1 ? LLONG_MAX : LLONG_MIN;
+ }
+#endif
return (long long int) x;
}
#include <math_private.h>
#include <libm-alias-double.h>
+#include <fix-fp-int-convert-overflow.h>
/* For LP64, lround is an alias for llround. */
#ifndef _LP64
FE_INVALID must be raised and the return value is
unspecified. */
#ifdef FE_INVALID
- if (sizeof (long int) == 4
+ if (FIX_DBL_LONG_CONVERT_OVERFLOW
+ && !(sign == -1
+ && (sizeof (long int) == 4
+ ? x > (double) LONG_MIN - 0.5
+ : x >= (double) LONG_MIN)))
+ {
+ feraiseexcept (FE_INVALID);
+ return sign == 1 ? LONG_MAX : LONG_MIN;
+ }
+ else if (!FIX_DBL_LONG_CONVERT_OVERFLOW
+ && sizeof (long int) == 4
&& x <= (double) LONG_MIN - 0.5)
{
/* If truncation produces LONG_MIN, the cast will not raise