diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-04-06 15:47:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-06 15:47:20 +0200 |
commit | ac591d9904e4e5cf7841b3e79caabf558d37db0e (patch) | |
tree | 70f3bd487e91feb4ca777dba214a09b17041da97 /core/math/math_funcs.h | |
parent | 72407a9cfbd4f58102972c0910429f3ab7006f07 (diff) | |
parent | f851c4aa330e1064a66db50be62db2466f4fb768 (diff) |
Merge pull request #59911 from bruvzg/cppcheck_fixes
Diffstat (limited to 'core/math/math_funcs.h')
-rw-r--r-- | core/math/math_funcs.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 44340b97ae..b741277872 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -473,16 +473,16 @@ public: uint32_t x = ci.ui; uint32_t sign = (unsigned short)(x >> 31); uint32_t mantissa; - uint32_t exp; + uint32_t exponent; uint16_t hf; // get mantissa mantissa = x & ((1 << 23) - 1); // get exponent bits - exp = x & (0xFF << 23); - if (exp >= 0x47800000) { + exponent = x & (0xFF << 23); + if (exponent >= 0x47800000) { // check if the original single precision float number is a NaN - if (mantissa && (exp == (0xFF << 23))) { + if (mantissa && (exponent == (0xFF << 23))) { // we have a single precision NaN mantissa = (1 << 23) - 1; } else { @@ -493,17 +493,18 @@ public: (uint16_t)(mantissa >> 13); } // check if exponent is <= -15 - else if (exp <= 0x38000000) { - /*// store a denorm half-float value or zero - exp = (0x38000000 - exp) >> 23; - mantissa >>= (14 + exp); - - hf = (((uint16_t)sign) << 15) | (uint16_t)(mantissa); - */ + else if (exponent <= 0x38000000) { + /* + // store a denorm half-float value or zero + exponent = (0x38000000 - exponent) >> 23; + mantissa >>= (14 + exponent); + + hf = (((uint16_t)sign) << 15) | (uint16_t)(mantissa); + */ hf = 0; //denormals do not work for 3D, convert to zero } else { hf = (((uint16_t)sign) << 15) | - (uint16_t)((exp - 0x38000000) >> 13) | + (uint16_t)((exponent - 0x38000000) >> 13) | (uint16_t)(mantissa >> 13); } |