From b558abbe27d65760615473b7bfa1c730311036f8 Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Fri, 26 Jun 2026 02:08:30 +0530 Subject: [PATCH] fixed #5260: return self from floor for values >= 2^52 --- eo-runtime/src/main/eo/number.eo | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/eo-runtime/src/main/eo/number.eo b/eo-runtime/src/main/eo/number.eo index 9945bba3bad..9abf67187c2 100644 --- a/eo-runtime/src/main/eo/number.eo +++ b/eo-runtime/src/main/eo/number.eo @@ -118,7 +118,11 @@ # the original, so we subtract `1` in that single case. [] > floor if. > @ - ^.is-finite.not + or. + ^.is-finite.not + or. + ^.gte 4503599627370496 + ^.lte -4503599627370496 ^ if. trunc.gt ^ @@ -394,6 +398,18 @@ -5.floor -5 + # Tests that floor of a very large positive number >= 2^52 returns itself. + [] +> tests-floor-of-large-positive-integer + eq. > @ + 100000000000000000000.floor + 100000000000000000000 + + # Tests that floor of a very large negative number <= -2^52 returns itself. + [] +> tests-floor-of-large-negative-integer + eq. > @ + -100000000000000000000.floor + -100000000000000000000 + # Tests that floor of zero returns zero. [] +> tests-floor-of-zero eq. > @