diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-05 07:36:28 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-05 07:36:28 +0000 |
commit | 0a5ac6a44809ec32ae6e836086708a64112bcfd0 (patch) | |
tree | baff9ea570775fd1ad1cc0219977fa529665e910 /numeric.c | |
parent | 6340d6336a41c00577f4c5c1060a779220681ca1 (diff) |
Revert r33407; half-baked patch.
"* numeric.c (ruby_float_step): improve floating point calculations."
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 23 |
1 files changed, 4 insertions, 19 deletions
@@ -1690,25 +1690,10 @@ ruby_float_step(VALUE from, VALUE to, VALUE step, int excl) } else { if (err>0.5) err=0.5; - if (excl) { - if (n>0) { - if (n<err) - n = 1; - else - n = floor(n - err) + 1; - } - } else { - n = floor(n + err) + 1; - } - if (end < (n-1)*unit+beg) { - for (i=0; i<n; i++) { - rb_yield(DBL2NUM((n-1-i)/(n-1)*beg+i/(n-1)*end)); - } - } - else { - for (i=0; i<n; i++) { - rb_yield(DBL2NUM(i*unit+beg)); - } + n = floor(n + err); + if (!excl || ((long)n)*unit+beg < end) n++; + for (i=0; i<n; i++) { + rb_yield(DBL2NUM(i*unit+beg)); } } return TRUE; |