libc/math: fix fmod family operation
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
parent
185de258bf
commit
8462b14d4e
@ -43,10 +43,8 @@ double fmod(double x, double div)
|
||||
{
|
||||
double n0;
|
||||
|
||||
x /= div;
|
||||
x = modf(x, &n0);
|
||||
x *= div;
|
||||
modf(x / div, &n0);
|
||||
|
||||
return x;
|
||||
return x - n0 * div;
|
||||
}
|
||||
#endif
|
||||
|
@ -39,9 +39,7 @@ float fmodf(float x, float div)
|
||||
{
|
||||
float n0;
|
||||
|
||||
x /= div;
|
||||
x = modff(x, &n0);
|
||||
x *= div;
|
||||
modff(x / div, &n0);
|
||||
|
||||
return x;
|
||||
return x - n0 * div;
|
||||
}
|
||||
|
@ -43,10 +43,8 @@ long double fmodl(long double x, long double div)
|
||||
{
|
||||
long double n0;
|
||||
|
||||
x /= div;
|
||||
x = modfl(x, &n0);
|
||||
x *= div;
|
||||
modfl(x / div, &n0);
|
||||
|
||||
return x;
|
||||
return x - n0 * div;
|
||||
}
|
||||
#endif
|
||||
|
@ -46,12 +46,12 @@ double modf(double x, double *iptr)
|
||||
}
|
||||
else if (fabs(x) < 1.0)
|
||||
{
|
||||
*iptr = (x * 0.0);
|
||||
*iptr = 0.0;
|
||||
return x;
|
||||
}
|
||||
else
|
||||
{
|
||||
*iptr = (double)(int64_t) x;
|
||||
*iptr = (double)(int64_t)x;
|
||||
return (x - *iptr);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ float modff(float x, float *iptr)
|
||||
}
|
||||
else if (fabsf(x) < 1.0F)
|
||||
{
|
||||
*iptr = (x * 0.0F);
|
||||
*iptr = 0.0F;
|
||||
return x;
|
||||
}
|
||||
else
|
||||
|
@ -49,12 +49,12 @@ long double modfl(long double x, long double *iptr)
|
||||
}
|
||||
else if (fabsl(x) < 1.0)
|
||||
{
|
||||
*iptr = (x * 0.0);
|
||||
*iptr = 0.0;
|
||||
return x;
|
||||
}
|
||||
else
|
||||
{
|
||||
*iptr = (long double)(int64_t) x;
|
||||
*iptr = (long double)(int64_t)x;
|
||||
return (x - *iptr);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user