summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-06 09:04:03 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-06 09:04:03 +0000
commitdee96209bfbb957538c7adeb01a65f3830749179 (patch)
tree3289aa4829f7fcb044cfa70341caaafd1aa086b0 /random.c
parent4263bb432accd9bd98654c3e8cc312414e7db906 (diff)
19991206
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/random.c b/random.c
index fbfa94e4e9..67c752d0f7 100644
--- a/random.c
+++ b/random.c
@@ -126,13 +126,12 @@ rb_f_rand(obj, vmax)
long val, max;
switch (TYPE(vmax)) {
- case T_BIGNUM:
- return rb_big_rand(vmax);
-
case T_FLOAT:
- if (RFLOAT(vmax)->value > LONG_MAX || RFLOAT(vmax)->value < LONG_MIN)
- return rb_big_rand(rb_dbl2big(RFLOAT(vmax)->value));
- break;
+ if (RFLOAT(vmax)->value <= LONG_MAX && RFLOAT(vmax)->value >= LONG_MIN)
+ break;
+ /* fall through */
+ case T_BIGNUM:
+ return rb_big_rand(vmax, RANDOM_NUMBER);
}
max = NUM2LONG(vmax);