summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-08 09:02:04 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-08 09:02:04 +0000
commitf92f8b565f2e749c58f0998fdcf6f23d52096fe3 (patch)
tree23930e9fcf0451f76eaf9458eea8070fcff8ee38 /random.c
parent5c9d3fac30ada76110bd0fcd31402e4bd979bb36 (diff)
* random.c (rb_f_rand): normalize bignum argument.
* sprintf.c (rb_f_sprintf): was decrementing width even if there is no sign character. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/random.c b/random.c
index 86c8198..b04bcdd 100644
--- a/random.c
+++ b/random.c
@@ -215,6 +215,11 @@ rb_f_rand(argc, argv, obj)
vmax = rb_dbl2big(RFLOAT(vmax)->value);
/* fall through */
case T_BIGNUM:
+ vmax = rb_big_norm(vmax);
+ if (FIXNUM_P(vmax)) {
+ max = FIX2INT(vmax);
+ break;
+ }
bignum:
{
long len = RBIGNUM(vmax)->len;