diff --git a/libs/libc/math/lib_libsqrtapprox.c b/libs/libc/math/lib_libsqrtapprox.c index c0cd0af18e..69c4bfda69 100644 --- a/libs/libc/math/lib_libsqrtapprox.c +++ b/libs/libc/math/lib_libsqrtapprox.c @@ -38,13 +38,16 @@ float lib_sqrtapprox(float x) { - int32_t i; + union + { + int32_t i; + float x; + } u; /* Floats + bit manipulation = +inf fun! */ - i = *((int32_t *) & x); - i = 0x1fc00000 + (i >> 1); - x = *((float *)&i); + u.x = x; + u.i = 0x1fc00000 + (u.i >> 1); - return x; + return u.x; }