Fixed error: comparing floating point with == or != is unsafe
This commit is contained in:
parent
6684535016
commit
456dde14f4
@ -620,7 +620,7 @@ namespace detail
|
|||||||
|
|
||||||
float const ExpSharedP = max(-15.f - 1.f, floor(log2(MaxColor))) + 1.0f + 15.f;
|
float const ExpSharedP = max(-15.f - 1.f, floor(log2(MaxColor))) + 1.0f + 15.f;
|
||||||
float const MaxShared = floor(MaxColor / pow(2.0f, (ExpSharedP - 15.f - 9.f)) + 0.5f);
|
float const MaxShared = floor(MaxColor / pow(2.0f, (ExpSharedP - 15.f - 9.f)) + 0.5f);
|
||||||
float const ExpShared = detail::compute_equal<float, std::numeric_limits<float>::is_iec559>::call(MaxShared, pow(2.0f, 9.0f)) ? ExpSharedP + 1.0f : ExpSharedP;
|
float const ExpShared = equal(MaxShared, pow(2.0f, 9.0f), epsilon<float>()) ? ExpSharedP + 1.0f : ExpSharedP;
|
||||||
|
|
||||||
uvec3 const ColorComp(floor(Color / pow(2.f, (ExpShared - 15.f - 9.f)) + 0.5f));
|
uvec3 const ColorComp(floor(Color / pow(2.f, (ExpShared - 15.f - 9.f)) + 0.5f));
|
||||||
|
|
||||||
|
@ -82,13 +82,13 @@ namespace detail
|
|||||||
if((ix>0x7f800000) || // x is nan
|
if((ix>0x7f800000) || // x is nan
|
||||||
(iy>0x7f800000)) // y is nan
|
(iy>0x7f800000)) // y is nan
|
||||||
return x+y;
|
return x+y;
|
||||||
if(compute_equal<float, std::numeric_limits<float>::is_iec559>::call(x, y))
|
if(equal(x, y, epsilon<float>()))
|
||||||
return y; // x=y, return y
|
return y; // x=y, return y
|
||||||
if(ix==0)
|
if(ix==0)
|
||||||
{ // x == 0
|
{ // x == 0
|
||||||
GLM_SET_FLOAT_WORD(x,(hy&0x80000000)|1);// return +-minsubnormal
|
GLM_SET_FLOAT_WORD(x,(hy&0x80000000)|1);// return +-minsubnormal
|
||||||
t = x*x;
|
t = x*x;
|
||||||
if(detail::compute_equal<float, true>::call(t, x))
|
if(equal(t, x, epsilon<float>()))
|
||||||
return t;
|
return t;
|
||||||
else
|
else
|
||||||
return x; // raise underflow flag
|
return x; // raise underflow flag
|
||||||
@ -137,13 +137,13 @@ namespace detail
|
|||||||
if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || // x is nan
|
if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || // x is nan
|
||||||
((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) // y is nan
|
((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) // y is nan
|
||||||
return x+y;
|
return x+y;
|
||||||
if(detail::compute_equal<double, true>::call(x, y))
|
if(equal(x, y, epsilon<double>()))
|
||||||
return y; // x=y, return y
|
return y; // x=y, return y
|
||||||
if((ix|lx)==0)
|
if((ix|lx)==0)
|
||||||
{ // x == 0
|
{ // x == 0
|
||||||
GLM_INSERT_WORDS(x, hy & 0x80000000, 1); // return +-minsubnormal
|
GLM_INSERT_WORDS(x, hy & 0x80000000, 1); // return +-minsubnormal
|
||||||
t = x*x;
|
t = x*x;
|
||||||
if(detail::compute_equal<double, true>::call(t, x))
|
if(equal(t, x, epsilon<double>()))
|
||||||
return t;
|
return t;
|
||||||
else
|
else
|
||||||
return x; // raise underflow flag
|
return x; // raise underflow flag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user