ruby-changes:7925
From: tadf <ko1@a...>
Date: Sun, 21 Sep 2008 21:21:50 +0900 (JST)
Subject: [ruby-changes:7925] Ruby:r19446 (trunk): * complex.c: added two macros.
tadf 2008-09-21 21:21:32 +0900 (Sun, 21 Sep 2008) New Revision: 19446 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19446 Log: * complex.c: added two macros. * rational.c: ditto. Modified files: trunk/ChangeLog trunk/complex.c trunk/rational.c Index: complex.c =================================================================== --- complex.c (revision 19445) +++ complex.c (revision 19446) @@ -195,6 +195,8 @@ 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 @@ 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 @@ 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 @@ 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); } Index: ChangeLog =================================================================== --- ChangeLog (revision 19445) +++ ChangeLog (revision 19446) @@ -1,3 +1,9 @@ +Sun Sep 21 21:20:24 2008 Tadayoshi Funaba <tadf@d...> + + * complex.c: added two macros. + + * rational.c: ditto. + Sun Sep 21 18:06:38 2008 Tadayoshi Funaba <tadf@d...> * complex.c (nucomp_s_convert): checks argc. Index: rational.c =================================================================== --- rational.c (revision 19445) +++ rational.c (revision 19446) @@ -167,6 +167,8 @@ 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 @@ 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 @@ 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 @@ 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 @@ static VALUE nurat_abs(VALUE self) { - if (!f_negative_p(self)) + if (f_positive_p(self)) return self; return f_negate(self); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/