mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
2000-06-05
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
76d09411e9
commit
ecd1aab526
9 changed files with 94 additions and 24 deletions
22
bignum.c
22
bignum.c
|
@ -520,6 +520,10 @@ rb_big_cmp(x, y)
|
|||
case T_BIGNUM:
|
||||
break;
|
||||
|
||||
case T_FLOAT:
|
||||
y = rb_dbl2big(RFLOAT(y)->value);
|
||||
break;
|
||||
|
||||
default:
|
||||
return rb_num_coerce_bin(x, y);
|
||||
}
|
||||
|
@ -542,8 +546,22 @@ static VALUE
|
|||
rb_big_eq(x, y)
|
||||
VALUE x, y;
|
||||
{
|
||||
if (rb_big_cmp(x, y) == INT2FIX(0)) return Qtrue;
|
||||
return Qfalse;
|
||||
switch (TYPE(y)) {
|
||||
case T_FIXNUM:
|
||||
y = rb_int2big(FIX2LONG(y));
|
||||
break;
|
||||
case T_BIGNUM:
|
||||
break;
|
||||
case T_FLOAT:
|
||||
y = rb_dbl2big(RFLOAT(y)->value);
|
||||
break;
|
||||
default:
|
||||
return Qfalse;
|
||||
}
|
||||
if (RBIGNUM(x)->sign != RBIGNUM(y)->sign) return Qfalse;
|
||||
if (RBIGNUM(x)->len != RBIGNUM(y)->len) return Qfalse;
|
||||
if (memcmp(BDIGITS(x),BDIGITS(y),RBIGNUM(y)->len) != 0) return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue