From 1376c3191b1bdf32b43b7b4bfef24ac5956941f5 Mon Sep 17 00:00:00 2001 From: tadf Date: Sun, 21 Sep 2008 12:21:32 +0000 Subject: * complex.c: added two macros. * rational.c: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- complex.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'complex.c') diff --git a/complex.c b/complex.c index 52acce544..827d79585 100644 --- a/complex.c +++ b/complex.c @@ -195,6 +195,8 @@ f_negative_p(VALUE x) return rb_funcall(x, '<', 1, ZERO); } +#define f_positive_p(x) (!f_negative_p(x)) + inline static VALUE f_zero_p(VALUE x) { @@ -203,6 +205,8 @@ f_zero_p(VALUE x) return rb_funcall(x, id_equal_p, 1, ZERO); } +#define f_nonzero_p(x) (!f_zero_p(x)) + inline static VALUE f_one_p(VALUE x) { @@ -487,7 +491,7 @@ static VALUE m_sqrt(VALUE x) { if (f_real_p(x)) { - if (!f_negative_p(x)) + if (f_positive_p(x)) return m_sqrt_bang(x); return f_complex_new2(rb_cComplex, ZERO, m_sqrt_bang(f_negate(x))); } @@ -1326,7 +1330,7 @@ numeric_abs2(VALUE self) static VALUE numeric_arg(VALUE self) { - if (!f_negative_p(self)) + if (f_positive_p(self)) return INT2FIX(0); return rb_const_get(rb_mMath, id_PI); } -- cgit