1
0
Fork 0
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:
ed 2020-04-27 09:28:51 +01:00
parent d663ded1f5
commit 77aff4658b

View file

@ -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