[前][次][番号順一覧][スレッド一覧]

ruby-changes:44767

From: nobu <ko1@a...>
Date: Sat, 19 Nov 2016 13:32:58 +0900 (JST)
Subject: [ruby-changes:44767] nobu:r56840 (trunk): ruby.h: rb_big_sign

nobu	2016-11-19 13:32:52 +0900 (Sat, 19 Nov 2016)

  New Revision: 56840

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56840

  Log:
    ruby.h: rb_big_sign
    
    * include/ruby/ruby.h (RBIGNUM_SIGN): use a wrapper function to
      return the sign bit, instead of comparing with 0.

  Modified files:
    trunk/bignum.c
    trunk/include/ruby/ruby.h
Index: bignum.c
===================================================================
--- bignum.c	(revision 56839)
+++ bignum.c	(revision 56840)
@@ -6691,6 +6691,12 @@ rb_big_abs(VALUE x) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6691
     return x;
 }
 
+int
+rb_big_sign(VALUE x)
+{
+    return BIGNUM_SIGN(x);
+}
+
 size_t
 rb_big_size(VALUE big)
 {
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 56839)
+++ include/ruby/ruby.h	(revision 56840)
@@ -1185,9 +1185,10 @@ void *rb_check_typeddata(VALUE, const rb https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1185
 #define RSTRUCT_SET(st, idx, v) rb_struct_aset(st, INT2NUM(idx), (v))
 #define RSTRUCT_GET(st, idx)    rb_struct_aref(st, INT2NUM(idx))
 
-#define RBIGNUM_SIGN(b) (RB_FIX2LONG(rb_big_cmp((b), RB_INT2FIX(0))) >= 0)
-#define RBIGNUM_POSITIVE_P(b) (RB_FIX2LONG(rb_big_cmp((b), RB_INT2FIX(0))) >= 0)
-#define RBIGNUM_NEGATIVE_P(b) (RB_FIX2LONG(rb_big_cmp((b), RB_INT2FIX(0))) < 0)
+int rb_big_sign(VALUE);
+#define RBIGNUM_SIGN(b) (rb_big_sign(b))
+#define RBIGNUM_POSITIVE_P(b) (RBIGNUM_SIGN(b)!=0)
+#define RBIGNUM_NEGATIVE_P(b) (RBIGNUM_SIGN(b)==0)
 
 #define R_CAST(st)   (struct st*)
 #define RBASIC(obj)  (R_CAST(RBasic)(obj))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]