swift
swift copied to clipboard
[SR-8798] BinaryFloatingPoint.random(in:) crashes on some valid ranges
| Previous ID | SR-8798 |
| Radar | None |
| Original Reporter | @hartbit |
| Type | Bug |
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Standard Library |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: e4ed61953fff624b3e51c4a4dfb662dd
Issue Description:
The following piece of code crashes at runtime:
extension BinaryFloatingPoint where Self.RawSignificand: FixedWidthInteger {
static func random() -> Self {
return random(in: -greatestFiniteMagnitude..<greatestFiniteMagnitude)
}
}
This should be fixed.
cc @stephentyrone, @Azoy
Yes, this is a known limitation of the algorithm that is currently in use; we're planning to fix it in 5.0.
@stephentyrone, is there a plan to fix it in 6.0?
I came here to report this exact issue. Sad to see it's been known for 6 years and still hasn't had any proper attention.
I just want a random finite float lol