summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-02 09:04:54 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-02 09:04:54 +0000
commit58e04b755a862f9dde91b0293f1998ed26ab73f4 (patch)
treee60ccc755d2807e75147e97eddf4304075777b3f /random.c
parent4b9666b700e57c11a4443c3c2819a3c127ce93a6 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/random.c b/random.c
index 0290873..028820d 100644
--- a/random.c
+++ b/random.c
@@ -147,8 +147,11 @@ rb_f_rand(argc, argv, obj)
}
switch (TYPE(vmax)) {
case T_FLOAT:
- if (RFLOAT(vmax)->value <= LONG_MAX && RFLOAT(vmax)->value >= LONG_MIN)
+ if (RFLOAT(vmax)->value <= LONG_MAX && RFLOAT(vmax)->value >= LONG_MIN) {
+ max = (long)RFLOAT(vmax)->value;
break;
+ }
+ vmax = rb_dbl2big(RFLOAT(vmax)->value);
/* fall through */
case T_BIGNUM:
return rb_big_rand(vmax, RANDOM_NUMBER);