Closed tanakamasayuki closed 5 years ago
https://en.wikipedia.org/wiki/Fast_inverse_square_root, invSqrt is no problem
Actual results are different.
\Arduino\libraries\M5StickC\src\utility\MahonyAHRS.cpp: In function 'float invSqrt(float)':
\Arduino\libraries\M5StickC\src\utility\MahonyAHRS.cpp:244:20: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
long i = *(long*)&y;
^
\Arduino\libraries\M5StickC\src\utility\MahonyAHRS.cpp:246:16: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
y = *(float*)&i;
^
There is a compiler warning. Probably broken by optimization.
invSqrt(float x) ~= 1 / sqrt(x)
Sorry
test code
output