summaryrefslogtreecommitdiffstats
path: root/complex.c
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-21 12:21:32 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-21 12:21:32 +0000
commit1376c3191b1bdf32b43b7b4bfef24ac5956941f5 (patch)
tree07794cd149a62ddbf8d5e5264e749d9c94a5100d /complex.c
parent482976cc242b1159b889c59a6d63a1b9d5a08eb6 (diff)
downloadruby-1376c3191b1bdf32b43b7b4bfef24ac5956941f5.tar.gz
ruby-1376c3191b1bdf32b43b7b4bfef24ac5956941f5.tar.xz
ruby-1376c3191b1bdf32b43b7b4bfef24ac5956941f5.zip
* 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
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c8
1 files changed, 6 insertions, 2 deletions
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);
}