summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-20 08:20:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-20 08:20:56 +0000
commit1abd3d4e38fda91ebb19e3b169b3096f74c8b539 (patch)
treea23c3e0aeb87462d446837f2fcfccdf4f86a270c /random.c
parent1ea6c81762ff15f5a4fc9c4e458a312492045c39 (diff)
random.c: refine error message
* random.c (rb_random_real): refine error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36480 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 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;