summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorS-H-GAMELINKS <gamelinks007@gmail.com>2020-11-17 18:41:21 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-11-20 11:47:47 +0900
commitc11c25baefa996fd16ac6b03e2c4cbe8a98b7237 (patch)
tree2f6a6f755965ac06bdcc3027961fe5b388a460bf
parentd79cdcb113ed63705f857ac2a7c323db398c4256 (diff)
fix code
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3769
-rw-r--r--numeric.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/numeric.c b/numeric.c
index 466df46..b4abefb 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1820,22 +1820,12 @@ rb_flo_is_finite_p(VALUE num)
return Qtrue;
}
-enum flo_prevnext_flags
-{
- FLOAT_PREV = 0,
- FLOAT_NEXT = 1
-};
-
static VALUE
-flo_prev_or_next(VALUE flo, int flag)
+flo_prev_or_next(VALUE flo, double value)
{
double x, y;
x = NUM2DBL(flo);
- if (flag == 1)
- y = nextafter(x, HUGE_VAL);
- else
- y = nextafter(x, -HUGE_VAL);
-
+ y = nextafter(x, value);
return DBL2NUM(y);
}
@@ -1894,7 +1884,7 @@ flo_prev_or_next(VALUE flo, int flag)
static VALUE
flo_next_float(VALUE vx)
{
- return flo_prev_or_next(vx, FLOAT_NEXT);
+ return flo_prev_or_next(vx, HUGE_VAL);
}
/*
@@ -1942,7 +1932,7 @@ flo_next_float(VALUE vx)
static VALUE
flo_prev_float(VALUE vx)
{
- return flo_prev_or_next(vx, FLOAT_PREV);
+ return flo_prev_or_next(vx, -HUGE_VAL);
}
/*