summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-09 22:28:42 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-09 22:28:42 +0000
commit662e3cf1f94bb50f6a27568c7526f867956e5b55 (patch)
treec2aa80d7fdd9598fcd612e59d6373f97b893dc21 /bignum.c
parentd54accfe3ff3fd8a139cc7b899fc1e20104dcc97 (diff)
downloadruby-662e3cf1f94bb50f6a27568c7526f867956e5b55.tar.gz
* eval.c (rb_load): put rb_load_file() in a thread critical
section. [ruby-dev:20490] * eval.c (compile): put rb_compile_string() in a thread critical section. * variable.c (rb_const_get_0): should not warn if constant is not defined. (ruby-bugs-ja PR#509) * bignum.c (rb_big2dbl): give a warning on overflow. (ruby-bugs-ja PR#510) * util.c (ruby_strtod): change MDMAXEXPT from 511 to 308. * pack.c (utf8_to_uv): long is sufficient. LONG_LONG is not required. * bignum.c (rb_big2str): support 32 bit (without `long long' type) machines. (ruby-bugs-ja PR#512) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/bignum.c b/bignum.c
index 5992662d42..9839f552fb 100644
--- a/bignum.c
+++ b/bignum.c
@@ -647,8 +647,11 @@ rb_big2str(x, base)
break;
}
j += 2;
+
hbase = base * base;
+#if SIZEOF_BDIGITS > 2
hbase *= hbase;
+#endif
t = rb_big_clone(x);
ds = BDIGITS(t);
@@ -666,7 +669,7 @@ rb_big2str(x, base)
num %= hbase;
}
if (ds[i-1] == 0) i--;
- k = 4;
+ k = SIZEOF_BDIGITS;
while (k--) {
c = (char)(num % base);
s[--j] = ruby_digitmap[(int)c];
@@ -839,7 +842,10 @@ rb_big2dbl(x)
while (i--) {
d = ds[i] + BIGRAD*d;
}
- if (isinf(d)) d = HUGE_VAL;
+ if (isinf(d)) {
+ rb_warn("Bignum out of Float range");
+ d = HUGE_VAL;
+ }
if (!RBIGNUM(x)->sign) d = -d;
return d;
}