diff --git a/modules/juce_core/maths/juce_Random.cpp b/modules/juce_core/maths/juce_Random.cpp index 9cca2dc6ab..bd9e3994ed 100644 --- a/modules/juce_core/maths/juce_Random.cpp +++ b/modules/juce_core/maths/juce_Random.cpp @@ -105,7 +105,8 @@ bool Random::nextBool() noexcept float Random::nextFloat() noexcept { - return static_cast (nextInt()) / (std::numeric_limits::max() + 1.0f); + auto result = static_cast (nextInt()) / (std::numeric_limits::max() + 1.0f); + return result == 1.0f ? 1.0f - std::numeric_limits::epsilon() : result; } double Random::nextDouble() noexcept