mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
Merged in lokeshbv/l-nuttx/libc_math (pull request #439)
Libc math: Error fixes in modf() and ceil() API's Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
@@ -41,8 +41,10 @@
|
|||||||
#ifdef CONFIG_HAVE_DOUBLE
|
#ifdef CONFIG_HAVE_DOUBLE
|
||||||
double ceil(double x)
|
double ceil(double x)
|
||||||
{
|
{
|
||||||
|
double x1 = x;
|
||||||
|
|
||||||
modf(x, &x);
|
modf(x, &x);
|
||||||
if (x > 0.0)
|
if (x1 > 0.0 && fabs(x1 - x) > 0.0)
|
||||||
{
|
{
|
||||||
x += 1.0;
|
x += 1.0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,10 @@
|
|||||||
|
|
||||||
float ceilf(float x)
|
float ceilf(float x)
|
||||||
{
|
{
|
||||||
|
float x1 = x;
|
||||||
|
|
||||||
modff(x, &x);
|
modff(x, &x);
|
||||||
if (x > 0.0F)
|
if (x1 > 0.0F && fabsf(x1 - x) > 0.0F)
|
||||||
{
|
{
|
||||||
x += 1.0F;
|
x += 1.0F;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,10 @@
|
|||||||
#ifdef CONFIG_HAVE_LONG_DOUBLE
|
#ifdef CONFIG_HAVE_LONG_DOUBLE
|
||||||
long double ceill(long double x)
|
long double ceill(long double x)
|
||||||
{
|
{
|
||||||
|
long double x1 = x;
|
||||||
|
|
||||||
modfl(x, &x);
|
modfl(x, &x);
|
||||||
if (x > 0.0)
|
if (x1 > 0.0 && fabsl(x1 - x) > 0.0)
|
||||||
{
|
{
|
||||||
x += 1.0;
|
x += 1.0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ double modf(double x, double *iptr)
|
|||||||
}
|
}
|
||||||
else if (fabs(x) < 1.0)
|
else if (fabs(x) < 1.0)
|
||||||
{
|
{
|
||||||
*iptr = 0.0;
|
*iptr = (x * 0.0);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ float modff(float x, float *iptr)
|
|||||||
}
|
}
|
||||||
else if (fabsf(x) < 1.0F)
|
else if (fabsf(x) < 1.0F)
|
||||||
{
|
{
|
||||||
*iptr = 0.0F;
|
*iptr = (x * 0.0F);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ long double modfl(long double x, long double *iptr)
|
|||||||
}
|
}
|
||||||
else if (fabs(x) < 1.0)
|
else if (fabs(x) < 1.0)
|
||||||
{
|
{
|
||||||
*iptr = 0.0;
|
*iptr = (x * 0.0);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user