From a288ff502ed5267898fd8e38d291c611befe7f0b Mon Sep 17 00:00:00 2001 From: mrkn Date: Mon, 7 Jan 2019 04:49:34 +0000 Subject: complex.c (f_divide): canonicalize a quotient Cannonicalize resultant real and imaginary parts when complex number divided by non-complex number. [Fix GH-2065] [Bug #15505] [ruby-core:90891] From: Joe Peric git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- complex.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'complex.c') diff --git a/complex.c b/complex.c index 8c7f007b44..6c94f9a764 100644 --- a/complex.c +++ b/complex.c @@ -843,10 +843,11 @@ f_divide(VALUE self, VALUE other, } if (k_numeric_p(other) && f_real_p(other)) { get_dat1(self); - - return f_complex_new2(CLASS_OF(self), - (*func)(dat->real, other), - (*func)(dat->imag, other)); + return f_complex_new2(CLASS_OF(self), + rb_rational_canonicalize( + (*func)(dat->real, other)), + rb_rational_canonicalize( + (*func)(dat->imag, other))); } return rb_num_coerce_bin(self, other, id); } -- cgit v1.2.3