diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-17 01:38:07 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-17 01:38:07 +0000 |
commit | 90cdde870d3e517b515446809129be69ef2a1981 (patch) | |
tree | 2468e859ae9c4df7bc94036c7e66788586a82229 /rational.c | |
parent | bb82e49632efff50688e903e656730398e541345 (diff) | |
download | bundler-90cdde870d3e517b515446809129be69ef2a1981.tar.gz |
Revert r42942; a revert requires a reason
* rational.c (nurat_div): reverted r28844, r28886 and r28887.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
-rw-r--r-- | rational.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/rational.c b/rational.c index 53bc11c4ef..a572dceb11 100644 --- a/rational.c +++ b/rational.c @@ -950,8 +950,19 @@ nurat_div(VALUE self, VALUE other) other, ONE, '/'); } } - else if (RB_TYPE_P(other, T_FLOAT)) + else if (RB_TYPE_P(other, T_FLOAT)) { + { + double x = RFLOAT_VALUE(other), den; + get_dat1(self); + + if (isnan(x)) return DBL2NUM(NAN); + if (isinf(x)) return INT2FIX(0); + if (x != 0.0 && modf(x, &den) == 0.0) { + return rb_rational_raw2(dat->num, f_mul(rb_dbl2big(den), dat->den)); + } + } return rb_funcall(f_to_f(self), '/', 1, other); + } else if (RB_TYPE_P(other, T_RATIONAL)) { if (f_zero_p(other)) rb_raise_zerodiv(); |