* [ruby-core:95081] [Ruby master Bug#16180] Random.rand(max) ignores / is broken when max ceiling value is a float
[not found] <redmine.issue-16180.20190925110724@ruby-lang.org>
@ 2019-09-25 11:07 ` nigel
2019-09-25 11:34 ` [ruby-core:95083] " hanmac
2019-09-25 11:37 ` [ruby-core:95084] " nobu
2 siblings, 0 replies; 3+ messages in thread
From: nigel @ 2019-09-25 11:07 UTC (permalink / raw)
To: ruby-core
Issue #16180 has been reported by BillyRuffian (Nigel Brookes-Thomas).
----------------------------------------
Bug #16180: Random.rand(max) ignores / is broken when max ceiling value is a float
https://bugs.ruby-lang.org/issues/16180
* Author: BillyRuffian (Nigel Brookes-Thomas)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
ruby 2.7.0preview1 (2019-05-31 trunk c55db6aa271df4a689dc8eb0039c929bf6ed43ff) [x86_64-darwin18]
Calling `rand` with a float of > 1 always return 0.
Calling `rand` with a float 0 < value > 1 will ignore the ceiling value.
e.g.
```
rand(1.1)
=> 0
rand(1.1)
=> 0
rand(0.5)
=> 0.9501516156613756
rand(0.5)
=> 0.6864252478379304
```
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:95083] [Ruby master Bug#16180] Random.rand(max) ignores / is broken when max ceiling value is a float
[not found] <redmine.issue-16180.20190925110724@ruby-lang.org>
2019-09-25 11:07 ` [ruby-core:95081] [Ruby master Bug#16180] Random.rand(max) ignores / is broken when max ceiling value is a float nigel
@ 2019-09-25 11:34 ` hanmac
2019-09-25 11:37 ` [ruby-core:95084] " nobu
2 siblings, 0 replies; 3+ messages in thread
From: hanmac @ 2019-09-25 11:34 UTC (permalink / raw)
To: ruby-core
Issue #16180 has been updated by Hanmac (Hans Mackowiak).
your cases are documented there: https://ruby-doc.org/core-2.6.4/Kernel.html#method-i-rand
`When max.abs is greater than or equal to 1, rand returns a pseudo-random integer greater than or equal to 0 and less than max.to_i.abs.`
`Negative or floating point values for max are allowed, but may give surprising results.`
----------------------------------------
Bug #16180: Random.rand(max) ignores / is broken when max ceiling value is a float
https://bugs.ruby-lang.org/issues/16180#change-81715
* Author: BillyRuffian (Nigel Brookes-Thomas)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
ruby 2.7.0preview1 (2019-05-31 trunk c55db6aa271df4a689dc8eb0039c929bf6ed43ff) [x86_64-darwin18]
Calling `rand` with a float of > 1 always return 0.
Calling `rand` with a float 0 < value > 1 will ignore the ceiling value.
e.g.
```
rand(1.1)
=> 0
rand(1.1)
=> 0
rand(0.5)
=> 0.9501516156613756
rand(0.5)
=> 0.6864252478379304
```
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:95084] [Ruby master Bug#16180] Random.rand(max) ignores / is broken when max ceiling value is a float
[not found] <redmine.issue-16180.20190925110724@ruby-lang.org>
2019-09-25 11:07 ` [ruby-core:95081] [Ruby master Bug#16180] Random.rand(max) ignores / is broken when max ceiling value is a float nigel
2019-09-25 11:34 ` [ruby-core:95083] " hanmac
@ 2019-09-25 11:37 ` nobu
2 siblings, 0 replies; 3+ messages in thread
From: nobu @ 2019-09-25 11:37 UTC (permalink / raw)
To: ruby-core
Issue #16180 has been updated by nobu (Nobuyoshi Nakada).
Status changed from Open to Rejected
If you want to random `Float` values up to `max`, use `Random#rand` or `Random.rand` instead of `Kernel#rand`.
----------------------------------------
Bug #16180: Random.rand(max) ignores / is broken when max ceiling value is a float
https://bugs.ruby-lang.org/issues/16180#change-81716
* Author: BillyRuffian (Nigel Brookes-Thomas)
* Status: Rejected
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
ruby 2.7.0preview1 (2019-05-31 trunk c55db6aa271df4a689dc8eb0039c929bf6ed43ff) [x86_64-darwin18]
Calling `rand` with a float of > 1 always return 0.
Calling `rand` with a float 0 < value > 1 will ignore the ceiling value.
e.g.
```
rand(1.1)
=> 0
rand(1.1)
=> 0
rand(0.5)
=> 0.9501516156613756
rand(0.5)
=> 0.6864252478379304
```
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-25 11:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-16180.20190925110724@ruby-lang.org>
2019-09-25 11:07 ` [ruby-core:95081] [Ruby master Bug#16180] Random.rand(max) ignores / is broken when max ceiling value is a float nigel
2019-09-25 11:34 ` [ruby-core:95083] " hanmac
2019-09-25 11:37 ` [ruby-core:95084] " nobu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).