summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-09 15:43:15 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-09 16:00:18 +0900
commitc47cd4be28840159251b4c66df71e10e979316a0 (patch)
treec1ab02c7a71969911cde18783ebc81697ceccc31 /enumerator.c
parentb7e0831e8f1f84a9440e42a27b2d7b15c65ca9aa (diff)
Removed duplicated code
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c31
1 files changed, 1 insertions, 30 deletions
diff --git a/enumerator.c b/enumerator.c
index fa30a59..5d5c382 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -3806,35 +3806,6 @@ arith_seq_each(VALUE self)
return self;
}
-static double
-arith_seq_float_step_size(double beg, double end, double step, int excl)
-{
- double const epsilon = DBL_EPSILON;
- double n, err;
-
- if (step == 0) {
- return HUGE_VAL;
- }
- n = (end - beg) / step;
- err = (fabs(beg) + fabs(end) + fabs(end - beg)) / fabs(step) * epsilon;
- if (isinf(step)) {
- return step > 0 ? beg <= end : beg >= end;
- }
- if (err > 0.5) err = 0.5;
- if (excl) {
- if (n <= 0) return 0;
- if (n < 1)
- n = 0;
- else
- n = floor(n - err);
- }
- else {
- if (n < 0) return 0;
- n = floor(n + err);
- }
- return n + 1;
-}
-
/*
* call-seq:
* aseq.size -> num or nil
@@ -3868,7 +3839,7 @@ arith_seq_size(VALUE self)
ee = NUM2DBL(e);
}
- n = arith_seq_float_step_size(NUM2DBL(b), ee, NUM2DBL(s), x);
+ n = ruby_float_step_size(NUM2DBL(b), ee, NUM2DBL(s), x);
if (isinf(n)) return DBL2NUM(n);
if (POSFIXABLE(n)) return LONG2FIX(n);
return rb_dbl2big(n);