Is there any particular reason for `Random` to not...
# announcements
l
Is there any particular reason for
Random
to not have range-based float generation?
v
Mostly to keep API simple and not bloated with every possible overload. Basically, once you have
nextBits
you can implement every other method as extension on top of
nextBits
, but it can be ineffective and complicates delegation to platform-specific implementations. So only essential and common (for some definition of “essential” and “common” 🙂) API was introduced
l
But I mean... All the others were implemented
It looks like Float was forgotten hahah
I tried to use it now
j
Most people don't need random floats in all fairness
l
I think it's also because floats are not evenly distributed across their possible values: You have more values between 0 and 1 than between max value and max value minus one, so it could be confusing to have less randomness because of an offset of the range.
a
See also https://youtrack.jetbrains.com/issue/KT-29306 for updates on this.
l
Thanks all!