summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog4
-rw-r--r--random.c5
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f7721c0f2f..06082f9d00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Jul 20 17:20:54 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * random.c (rb_random_real): refine error message.
+
Fri Jul 20 11:03:17 2012 Eric Hodel <drbrain@segment7.net>
* NEWS: Updated net/http for automatic proxy detection (#6546) and
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;