mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* numeric.c (flo_round): get rid of overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
47f5c15e8d
commit
a2b83212d6
2 changed files with 14 additions and 5 deletions
|
@ -1,3 +1,7 @@
|
|||
Sat Jun 21 16:21:07 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* numeric.c (flo_round): get rid of overflow.
|
||||
|
||||
Sat Jun 21 15:57:15 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/rdoc/parsers/parse_rb.rb (RDoc#collect_first_comment): skip
|
||||
|
|
15
numeric.c
15
numeric.c
|
@ -1299,11 +1299,16 @@ flo_round(int argc, VALUE *argv, VALUE num)
|
|||
while (--i >= 0)
|
||||
f = f*10.0;
|
||||
|
||||
if (ndigits < 0) number /= f;
|
||||
else number *= f;
|
||||
number = round(number);
|
||||
if (ndigits < 0) number *= f;
|
||||
else number /= f;
|
||||
if (isinf(f)) {
|
||||
if (ndigits < 0) number = 0;
|
||||
}
|
||||
else {
|
||||
if (ndigits < 0) number /= f;
|
||||
else number *= f;
|
||||
number = round(number);
|
||||
if (ndigits < 0) number *= f;
|
||||
else number /= f;
|
||||
}
|
||||
|
||||
if (ndigits > 0) return DOUBLE2NUM(number);
|
||||
|
||||
|
|
Loading…
Reference in a new issue