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
This commit is contained in:
parent
1ea6c81762
commit
1abd3d4e38
@ -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>
|
Fri Jul 20 11:03:17 2012 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
* NEWS: Updated net/http for automatic proxy detection (#6546) and
|
* NEWS: Updated net/http for automatic proxy detection (#6546) and
|
||||||
|
5
random.c
5
random.c
@ -932,7 +932,10 @@ rb_random_real(VALUE obj)
|
|||||||
if (!rnd) {
|
if (!rnd) {
|
||||||
VALUE v = rb_funcall2(obj, id_rand, 0, 0);
|
VALUE v = rb_funcall2(obj, id_rand, 0, 0);
|
||||||
double d = NUM2DBL(v);
|
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);
|
rb_raise(rb_eRangeError, "random number too big %g", d);
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user