summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-19 05:56:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-19 05:56:09 +0000
commitae23000c0e0e4f4af1b4462147d950549b3abdbe (patch)
tree15aff53955adad0d278851c21030857a07bd2f5f /bignum.c
parent71a202fc01c3284608f486dd8ebb95bc57203221 (diff)
* array.c (sort_2): *a - *b may overflow.
* array.c (ary_new): len*sizeof(VALUE) may be a positive value. * array.c (rb_ary_initialize): ditto. * object.c (rb_class_allocate_instance): move singleton class check from rb_obj_alloc(). * re.c (rb_reg_initialize): should not modify frozen Regexp. * ext/tcltklib/tcltklib.c (ip_init): allocation framework. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/bignum.c b/bignum.c
index 36092c8427..f6cfce8d70 100644
--- a/bignum.c
+++ b/bignum.c
@@ -609,7 +609,9 @@ rb_big2str(x, base)
return rb_fix2str(x, base);
}
i = RBIGNUM(x)->len;
- if (i == 0) return rb_str_new2("0");
+ if (i == 0 || (i == 1 && BDIGITS(x)[0] == 0)) {
+ return rb_str_new2("0");
+ }
if (base == 10) {
j = (SIZEOF_BDIGITS/sizeof(char)*CHAR_BIT*i*241L)/800+2;
hbase = 10000;
@@ -846,15 +848,7 @@ rb_big_cmp(x, y)
break;
case T_FLOAT:
- {
- double d = rb_big2dbl(x);
-
- if (d == RFLOAT(y)->value) return INT2FIX(0);
- if (d > RFLOAT(y)->value) return INT2FIX(1);
- if (d < RFLOAT(y)->value) return INT2FIX(-1);
- rb_raise(rb_eFloatDomainError, "comparing NaN");
- }
- break;
+ return rb_dbl_cmp(rb_big2dbl(x), RFLOAT(y)->value);
default:
return rb_num_coerce_bin(x, y);