Fix implicit inexact conversion

Clang 10's -Wimplicit-int-float-conversion complains that MAX = 2147483647 cannot be exactly represented as a float. Use an explicit conversion to suppress the warning locally. Note that this value's usage to produce a random boolean doesn't critically depend on exact conversion. Bug: b/152777669 Change-Id: I1136ca16dcb842b97f4a76a6ed3e1c3333e814f8 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/51488Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Commit-Queue: Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent b9e179f1
......@@ -50,7 +50,7 @@ uint64_t RandomNumberGenerator::next(uint64_t Max) {
}
bool RandomNumberGeneratorWrapper::getTrueWithProbability(float Probability) {
return RNG.next(MAX) < Probability * MAX;
return static_cast<float>(RNG.next(MAX)) < Probability * static_cast<float>(MAX);
}
} // end of namespace Ice
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment