Fixed Visual Studio float math bug in debug
This commit is contained in:
parent
59fcb54926
commit
9a5c5163e1
1 changed files with 9 additions and 4 deletions
|
@ -66,12 +66,17 @@ namespace
|
|||
{
|
||||
|
||||
// Returns the next representable floating point value without using conversion to integer.
|
||||
template <typename FloatT> FloatT NextFloat(FloatT x, int dir = 1)
|
||||
template <typename FloatT> FloatT NextFloat(FloatT const x, int dir = 1)
|
||||
{
|
||||
FloatT d = numeric_limits<FloatT>::denorm_min();
|
||||
while (x + dir * d == x)
|
||||
FloatT d = dir * numeric_limits<FloatT>::denorm_min();
|
||||
while (true)
|
||||
{
|
||||
FloatT y = x;
|
||||
y += d;
|
||||
if (x != y)
|
||||
return y;
|
||||
d *= 2;
|
||||
return x + dir * d;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FloatT> void TestMaxULPs()
|
||||
|
|
Reference in a new issue