summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
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 197a80f529..a1fb3a800b 100644
--- a/random.c
+++ b/random.c
@@ -932,7 +932,10 @@ rb_random_real(VALUE obj)
if (!rnd) {
VALUE v = rb_funcall2(obj, id_rand, 0, 0);
double d = NUM2DBL(v);
- if (d < 0.0 || d >= 1.0) {
+ if (d < 0.0) {
+ rb_raise(rb_eRangeError, "random number too small %g", d);
+ }
+ else if (d >= 1.0) {
rb_raise(rb_eRangeError, "random number too big %g", d);
}
return d;