diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-20 08:20:56 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-20 08:20:56 +0000 |
commit | 1abd3d4e38fda91ebb19e3b169b3096f74c8b539 (patch) | |
tree | a23c3e0aeb87462d446837f2fcfccdf4f86a270c /random.c | |
parent | 1ea6c81762ff15f5a4fc9c4e458a312492045c39 (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.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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; |