From bbb5a6d6f741be235abccff4da4cc424085869e6 Mon Sep 17 00:00:00 2001 From: tadf Date: Tue, 10 Aug 2010 12:20:49 +0000 Subject: * complex.c (nucomp_to_[ifr]): don't allow complex with in-exact imaginary zero to be converted. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- complex.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'complex.c') diff --git a/complex.c b/complex.c index 1052c0c458..b88f6b980b 100644 --- a/complex.c +++ b/complex.c @@ -1296,7 +1296,7 @@ nucomp_to_i(VALUE self) { get_dat1(self); - if (f_nonzero_p(dat->imag)) { + if (k_inexact_p(dat->imag) || f_nonzero_p(dat->imag)) { VALUE s = f_to_s(self); rb_raise(rb_eRangeError, "can't convert %s into Integer", StringValuePtr(s)); @@ -1315,7 +1315,7 @@ nucomp_to_f(VALUE self) { get_dat1(self); - if (f_nonzero_p(dat->imag)) { + if (k_inexact_p(dat->imag) || f_nonzero_p(dat->imag)) { VALUE s = f_to_s(self); rb_raise(rb_eRangeError, "can't convert %s into Float", StringValuePtr(s)); @@ -1334,7 +1334,7 @@ nucomp_to_r(VALUE self) { get_dat1(self); - if (f_nonzero_p(dat->imag)) { + if (k_inexact_p(dat->imag) || f_nonzero_p(dat->imag)) { VALUE s = f_to_s(self); rb_raise(rb_eRangeError, "can't convert %s into Rational", StringValuePtr(s)); -- cgit v1.2.3