зеркало из https://github.com/github/ruby.git
numeric.c: round as double
* numeric.c (flo_round): compare as double, not long double with i387. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
286eec2646
Коммит
558b9d05b2
|
@ -2007,10 +2007,10 @@ flo_round(int argc, VALUE *argv, VALUE num)
|
|||
f = pow(10, ndigits);
|
||||
x = round(number * f);
|
||||
if (x > 0) {
|
||||
if ((x + 0.5) / f <= number) x += 1;
|
||||
if ((double)((x + 0.5) / f) <= number) x += 1;
|
||||
}
|
||||
else {
|
||||
if ((x - 0.5) / f >= number) x -= 1;
|
||||
if ((double)((x - 0.5) / f) >= number) x -= 1;
|
||||
}
|
||||
return DBL2NUM(x / f);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче