[SR-12765] BinaryFloatingPoint.random(in:) cannot produce all values in range #55210
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Additional Detail from JIRA
md5: a098fd3f86f235d183201c32511e97cf
Issue Description:
The
random
methods onBinaryFloatingPoint
are documented with:However, the current implementation chooses randomly among 2ⁿ evenly-spaced values in the range, where n is one more than the significand bit-count.
For ranges that span several binades, this coarse-grained comb will miss many representable values in the range.
Furthermore, it will also trap on very large ranges (SR-8798) and it will trap on types where
significandBitCount == RawSignificand.bitWidth
.I have written a replacement implementation that solves all of these issues, however I have never contributed significant code to the Swift project before and I would appreciate guidance on how to proceed.
The text was updated successfully, but these errors were encountered: