libc/math: Fix warning: dereferencing type-punned pointer will break strict-aliasing rules
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I15aa5d664c20ea7bb95ba60e056134d2ff933db9
This commit is contained in:
parent
43b613877d
commit
b71c491f00
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user