mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5f03f753ee
commit
6839d47eb8
2 changed files with 10 additions and 3 deletions
6
bignum.c
6
bignum.c
|
@ -6691,6 +6691,12 @@ rb_big_abs(VALUE x)
|
|||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
rb_big_sign(VALUE x)
|
||||
{
|
||||
return BIGNUM_SIGN(x);
|
||||
}
|
||||
|
||||
size_t
|
||||
rb_big_size(VALUE big)
|
||||
{
|
||||
|
|
|
@ -1185,9 +1185,10 @@ void *rb_check_typeddata(VALUE, const rb_data_type_t *);
|
|||
#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))
|
||||
|
|
Loading…
Reference in a new issue