summaryrefslogtreecommitdiff
path: root/rational.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
commitcbae6d09113ff3ff6c07af2ae341b7384fa97667 (patch)
tree07794cd149a62ddbf8d5e5264e749d9c94a5100d /rational.c
parenta46544a4f9d31a2df3f9f2538de3fcb9715231fc (diff)
* complex.c: added two macros.
* rational.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/rational.c b/rational.c
index fea6f63ab8..3b352ea9da 100644
--- a/rational.c
+++ b/rational.c
@@ -167,6 +167,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)
{
@@ -175,6 +177,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)
{
@@ -280,7 +284,7 @@ inline static VALUE
f_gcd(VALUE x, VALUE y)
{
VALUE r = f_gcd_orig(x, y);
- if (!f_zero_p(r)) {
+ if (f_nonzero_p(r)) {
assert(f_zero_p(f_mod(x, r)));
assert(f_zero_p(f_mod(y, r)));
}
@@ -366,8 +370,8 @@ f_rational_new_bang1(VALUE klass, VALUE x)
inline static VALUE
f_rational_new_bang2(VALUE klass, VALUE x, VALUE y)
{
- assert(!f_negative_p(y));
- assert(!f_zero_p(y));
+ assert(f_positive_p(y));
+ assert(f_nonzero_p(y));
return nurat_s_new_internal(klass, x, y);
}
@@ -955,7 +959,7 @@ nurat_quotrem(VALUE self, VALUE other)
static VALUE
nurat_abs(VALUE self)
{
- if (!f_negative_p(self))
+ if (f_positive_p(self))
return self;
return f_negate(self);
}