File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed
Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -87,15 +87,10 @@ float _electricalAngle(float shaft_angle, int pole_pairs) {
8787// https://reprap.org/forum/read.php?147,219210
8888// https://en.wikipedia.org/wiki/Fast_inverse_square_root
8989__attribute__ ((weak)) float _sqrtApprox(float number) {// low in fat
90- // float x;
91- // const float f = 1.5F; // better precision
92-
93- // x = number * 0.5F;
94- float y;
95- y = number;
96- uint32_t i = *reinterpret_cast <uint32_t *>(&y);
97- i = 0x5f375a86 - ( i >> 1 );
98- y = *reinterpret_cast <float *>(&i);
99- // y = y * ( f - ( x * y * y ) ); // better precision
100- return number * y;
90+ union {
91+ float f;
92+ uint32_t i;
93+ } y = { .f = number };
94+ y.i = 0x5f375a86 - ( y.i >> 1 );
95+ return number * y.f ;
10196}
You can’t perform that action at this time.
0 commit comments