From 033244c1b2b23c3f70a2a7c5cbdef570fdb9220e Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 22 Nov 2011 01:47:35 +0000 Subject: * numeric.c (ruby_float_step): improve floating point calculations. [ruby-core:35753] [Bug #4576] * numeric.c (ruby_float_step): correct the error of floating point numbers on the excluding case. patched by Masahiro Tanaka [ruby-core:39608] * numeric.c (ruby_float_step): use the end value when the current value is greater than or equal to the end value. patched by Akira Tanaka [ruby-core:39612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 +++++++++++++ numeric.c | 19 +++++++++++++++---- test/ruby/test_float.rb | 29 +++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2f1b3bcf8..0d7de6fed6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Tue Nov 22 10:46:57 2011 NARUSE, Yui + + * numeric.c (ruby_float_step): improve floating point calculations. + [ruby-core:35753] [Bug #4576] + + * numeric.c (ruby_float_step): correct the error of floating point + numbers on the excluding case. + patched by Masahiro Tanaka [ruby-core:39608] + + * numeric.c (ruby_float_step): use the end value when the current + value is greater than or equal to the end value. + patched by Akira Tanaka [ruby-core:39612] + Tue Nov 22 06:59:21 2011 Tanaka Akira * test/ruby/test_io.rb (test_fcntl_dupfd): there is no known platform diff --git a/numeric.c b/numeric.c index e749a396d2..c8616f5f73 100644 --- a/numeric.c +++ b/numeric.c @@ -1690,10 +1690,21 @@ ruby_float_step(VALUE from, VALUE to, VALUE step, int excl) } else { if (err>0.5) err=0.5; - n = floor(n + err); - if (!excl || ((long)n)*unit+beg < end) n++; - for (i=0; i