summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-05 09:01:07 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-05 09:01:07 +0000
commit656d6d28704943d2960b20761b6d05386086e8a2 (patch)
treec99fec4f83ee9eb51430be6aaec27682c7dc6367 /bignum.c
parent7f3aa8b9ea9aaf38f4167e95ba86dd5d3766554e (diff)
2000-06-05
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/bignum.c b/bignum.c
index c4f181fc70..fb0dafb142 100644
--- a/bignum.c
+++ b/bignum.c
@@ -459,6 +459,10 @@ rb_big_cmp(x, y)
y = rb_int2big(FIX2LONG(y));
break;
+ case T_FLOAT:
+ y = rb_dbl2big(RFLOAT(y)->value);
+ break;
+
case T_BIGNUM:
break;
@@ -484,8 +488,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