bug patch for frexpf function

This commit is contained in:
zouboan 2022-01-21 22:46:34 +08:00 committed by Alan Carvalho de Assis
parent a32381ca32
commit a310b0952f

View File

@ -37,6 +37,21 @@
float frexpf(float x, int *exponent)
{
*exponent = (int)ceilf(log2f(x));
return x / ldexpf(1.0F, *exponent);
float res;
*exponent = (int)ceilf(log2f(fabsf(x)));
res = x / ldexpf(1.0F, *exponent);
if (res >= 1.0)
{
res -= 0.5;
*exponent += 1;
}
if (res <= -1.0)
{
res += 0.5;
*exponent += 1;
}
return res;
}