aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--rational.c13
2 files changed, 12 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 12fd67dcc6..65a793d1cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,10 +8,6 @@ Mon Sep 16 00:44:23 2013 Masaki Matsushita <glass.saga@gmail.com>
* ext/socket/mkconstants.rb: define MSG_FASTOPEN.
[ruby-core:57138] [Feature #8897]
-Sun Sep 15 13:31:23 2013 Tadayoshi Funaba <tadf@dotrb.org>
-
- * rational.c (nurat_div): reverted r28844, r28886 and r28887.
-
Sat Sep 14 06:08:10 2013 Eric Hodel <drbrain@segment7.net>
* dir.c (dir_s_glob): [DOC] Improve wording and layout.
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();