mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-29 02:40:05 +00:00
Fixed an edge case in Random::nextFloat() for dividends approaching std::numeric_limits<uint32>::max()
This commit is contained in:
parent
d663ded1f5
commit
77aff4658b
1 changed files with 2 additions and 1 deletions
|
|
@ -105,7 +105,8 @@ bool Random::nextBool() noexcept
|
|||
|
||||
float Random::nextFloat() noexcept
|
||||
{
|
||||
return static_cast<uint32> (nextInt()) / (std::numeric_limits<uint32>::max() + 1.0f);
|
||||
auto result = static_cast<uint32> (nextInt()) / (std::numeric_limits<uint32>::max() + 1.0f);
|
||||
return result == 1.0f ? 1.0f - std::numeric_limits<float>::epsilon() : result;
|
||||
}
|
||||
|
||||
double Random::nextDouble() noexcept
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue