From 473df115452d3a62b4b53f56f579c93ac40ce1b4 Mon Sep 17 00:00:00 2001 From: gogotanaka Date: Sat, 25 Oct 2014 20:13:49 -0700 Subject: [PATCH 2/3] Update complex.c --- complex.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/complex.c b/complex.c index b65bc8a..8be454c 100644 --- a/complex.c +++ b/complex.c @@ -1080,14 +1080,18 @@ nucomp_true(VALUE self) /* * call-seq: - * cmp.real? -> false + * cmp.real? -> true or false * - * Returns false. + * Returns true if imaginary part is 0. + * + * Complex(7).real? #=> true + * Complex(9, -4).real? #=> false */ static VALUE -nucomp_false(VALUE self) +nucomp_real_p(VALUE self) { - return Qfalse; + get_dat1(self); + return f_zero_p(dat->imag); } #if 0 @@ -2150,7 +2154,7 @@ Init_Complex(void) rb_define_method(rb_cComplex, "~", nucomp_conj, 0); /* gcc */ #endif - rb_define_method(rb_cComplex, "real?", nucomp_false, 0); + rb_define_method(rb_cComplex, "real?", nucomp_real_p, 0); #if 0 rb_define_method(rb_cComplex, "complex?", nucomp_true, 0); rb_define_method(rb_cComplex, "exact?", nucomp_exact_p, 0); -- 1.8.5.2 (Apple Git-48)