mirror of
https://git.planet-casio.com/Lephenixnoir/OpenLibm.git
synced 2025-07-11 14:57:34 +02:00
updates to s_round.c from FreeBSD
This commit is contained in:
parent
3566e32d84
commit
9ca11f20c6
1 changed files with 7 additions and 5 deletions
|
@ -34,19 +34,21 @@ DLLEXPORT double
|
||||||
round(double x)
|
round(double x)
|
||||||
{
|
{
|
||||||
double t;
|
double t;
|
||||||
|
uint32_t hx;
|
||||||
|
|
||||||
if (!isfinite(x))
|
GET_HIGH_WORD(hx, x);
|
||||||
return (x);
|
if ((hx & 0x7fffffff) == 0x7ff00000)
|
||||||
|
return (x + x);
|
||||||
|
|
||||||
if (x >= 0.0) {
|
if (!(hx & 0x80000000)) {
|
||||||
t = floor(x);
|
t = floor(x);
|
||||||
if (t - x <= -0.5)
|
if (t - x <= -0.5)
|
||||||
t += 1.0;
|
t += 1;
|
||||||
return (t);
|
return (t);
|
||||||
} else {
|
} else {
|
||||||
t = floor(-x);
|
t = floor(-x);
|
||||||
if (t + x <= -0.5)
|
if (t + x <= -0.5)
|
||||||
t += 1.0;
|
t += 1;
|
||||||
return (-t);
|
return (-t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue