If we’re discussing Swift’s floating point random-in-range methods, then I would like to point out that the original proposal SE–202 did not fully specify the semantics, but the author said in the review thread that the intended behavior was to function as if a real number were chosen uniformly in the range, then rounded to a representable value.
This is further supported by the accompanying documentation comment in the standard library:
However those semantics were never implemented. The implementation instead selects among equally-spaced values, which leads to a few problems such as:
[SR-8798] BinaryFloatingPoint.random(in:) crashes on some valid ranges
[SR-12765] BinaryFloatingPoint.random(in:) cannot produce all values in range
Some years back I drafted a PR to address these issues and implement the intended uniform-real-then-round semantics. However that PR remains unmerged, perhaps in part because my implementation was rather complicated. I expect it should be possible to simplify the code, but I haven’t gone back to try.
Also worth mentioning that changes like this were expressly foreseen and expected, as the very same doc comment states: