summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-16 08:44:32 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-16 08:44:32 +0000
commit984729ba3016a1fd4b371edef71fcb8b7f3956b4 (patch)
treebf18efcaf395a94083d3b4e937348c038c3695e5 /bignum.c
parent3fe481ae726a898b880a417d94185640ebcb6189 (diff)
* bignum.c (rb_big_float_cmp): support fixnum for argument x.
* numeric.c (fix_equal): use rb_big_float_cmp. (fix_cmp): ditto. (fix_gt): ditto. (fix_ge): ditto. (fix_lt): ditto. (fix_le): ditto. (flo_eq): ditto. (flo_cmp): use rb_big_float_cmp for fixnum argument. (flo_gt): ditto. (flo_ge): ditto. (flo_lt): ditto. (flo_le): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/bignum.c b/bignum.c
index 592c8f88ce..32dace5d6f 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1436,10 +1436,20 @@ rb_big_float_cmp(VALUE x, VALUE y)
{
double a = RFLOAT_VALUE(y);
+ if (isnan(a))
+ return Qnil;
if (isinf(a)) {
if (a > 0.0) return INT2FIX(-1);
else return INT2FIX(1);
}
+ if (FIXNUM_P(x)) {
+ double xd = (double)FIX2LONG(x);
+ if (xd < a)
+ return INT2FIX(-1);
+ if (xd > a)
+ return INT2FIX(1);
+ return INT2FIX(0);
+ }
return rb_dbl_cmp(rb_big2dbl(x), a);
}