summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-11-08 16:05:04 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-11-08 18:35:22 +0900
commit7cc4e147fc2fba1ef9e06cf50f1916acdb886a24 (patch)
tree27a94bcf85f1ee6fec261b7d873e4df7c58f27b4 /numeric.c
parent395738e8a5a14d432d17a9fe106f62f54a81c7aa (diff)
Get rid of implicit expansion to `long double` on ix86
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/numeric.c b/numeric.c
index da6595085d..7a28e32b27 100644
--- a/numeric.c
+++ b/numeric.c
@@ -2546,7 +2546,7 @@ double
ruby_float_step_size(double beg, double end, double unit, int excl)
{
const double epsilon = DBL_EPSILON;
- double n, err;
+ double d, n, err;
if (unit == 0) {
return HUGE_VAL;
@@ -2563,24 +2563,26 @@ ruby_float_step_size(double beg, double end, double unit, int excl)
n = 0;
else
n = floor(n - err);
+ d = +((n + 1) * unit) + beg;
if (beg < end) {
- if ((n+1)*unit+beg < end)
+ if (d < end)
n++;
}
else if (beg > end) {
- if ((n+1)*unit+beg > end)
+ if (d > end)
n++;
}
}
else {
if (n<0) return 0;
n = floor(n + err);
+ d = +((n + 1) * unit) + beg;
if (beg < end) {
- if ((n+1)*unit+beg <= end)
+ if (d <= end)
n++;
}
else if (beg > end) {
- if ((n+1)*unit+beg >= end)
+ if (d >= end)
n++;
}
}