about summary refs log tree commit diff
path: root/src/math/floorl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/floorl.c')
-rw-r--r--src/math/floorl.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/math/floorl.c b/src/math/floorl.c
index 961f9e89..16aaec48 100644
--- a/src/math/floorl.c
+++ b/src/math/floorl.c
@@ -6,11 +6,9 @@ long double floorl(long double x)
 	return floor(x);
 }
 #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#if LDBL_MANT_DIG == 64
-#define TOINT 0x1p63
-#elif LDBL_MANT_DIG == 113
-#define TOINT 0x1p112
-#endif
+
+static const long double toint = 1/LDBL_EPSILON;
+
 long double floorl(long double x)
 {
 	union ldshape u = {x};
@@ -21,9 +19,9 @@ long double floorl(long double x)
 		return x;
 	/* y = int(x) - x, where int(x) is an integer neighbor of x */
 	if (u.i.se >> 15)
-		y = x - TOINT + TOINT - x;
+		y = x - toint + toint - x;
 	else
-		y = x + TOINT - TOINT - x;
+		y = x + toint - toint - x;
 	/* special case because of non-nearest rounding modes */
 	if (e <= 0x3fff-1) {
 		FORCE_EVAL(y);