diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-28 04:40:58 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-28 04:40:58 +0000 |
commit | 1778ed59e7179d914ce8a35df3b79b0b9a715560 (patch) | |
tree | fe67be8cec29a6a9148b0804a3f8882baaef6126 /numeric.c | |
parent | 09ae127bade1d58705adfccb09a70403d8d909d5 (diff) | |
download | ruby-1778ed59e7179d914ce8a35df3b79b0b9a715560.tar.gz |
numeric.c: reduce fdiv
* numeric.c (rb_int_fdiv_double): reduce first for more precise
result. [ruby-core:78886] [Bug #13078]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -3614,6 +3614,13 @@ fix_fdiv_double(VALUE x, VALUE y) double rb_int_fdiv_double(VALUE x, VALUE y) { + if (RB_INTEGER_TYPE_P(y) && !FIXNUM_ZERO_P(y)) { + VALUE gcd = rb_gcd(x, y); + if (!FIXNUM_ZERO_P(gcd)) { + x = rb_int_idiv(x, gcd); + y = rb_int_idiv(y, gcd); + } + } if (FIXNUM_P(x)) { return fix_fdiv_double(x, y); } |