summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-05 07:36:28 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-05 07:36:28 +0000
commit0a5ac6a44809ec32ae6e836086708a64112bcfd0 (patch)
treebaff9ea570775fd1ad1cc0219977fa529665e910 /numeric.c
parent6340d6336a41c00577f4c5c1060a779220681ca1 (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.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/numeric.c b/numeric.c
index 166dc520de..6d3c1432e8 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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;