Catch up on upstream's round/roundf/roundl.
Not sure how we missed these, but better late than never... Change-Id: Ib08d1bb6e340a1907cbeb1cbe220e33f70642bdc
This commit is contained in:
parent
8dd3b65f2d
commit
14538ca75e
@ -27,25 +27,34 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <math.h>
|
#include <float.h>
|
||||||
|
|
||||||
|
#include "math.h"
|
||||||
|
#include "math_private.h"
|
||||||
|
|
||||||
double
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LDBL_MANT_DIG == 53)
|
||||||
|
__weak_reference(round, roundl);
|
||||||
|
#endif
|
||||||
|
@ -27,25 +27,28 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <math.h>
|
#include "math.h"
|
||||||
|
#include "math_private.h"
|
||||||
|
|
||||||
float
|
float
|
||||||
roundf(float x)
|
roundf(float x)
|
||||||
{
|
{
|
||||||
float t;
|
float t;
|
||||||
|
uint32_t hx;
|
||||||
|
|
||||||
if (!isfinite(x))
|
GET_FLOAT_WORD(hx, x);
|
||||||
return (x);
|
if ((hx & 0x7fffffff) == 0x7f800000)
|
||||||
|
return (x + x);
|
||||||
|
|
||||||
if (x >= 0.0) {
|
if (!(hx & 0x80000000)) {
|
||||||
t = floorf(x);
|
t = floorf(x);
|
||||||
if (t - x <= -0.5)
|
if (t - x <= -0.5F)
|
||||||
t += 1.0;
|
t += 1;
|
||||||
return (t);
|
return (t);
|
||||||
} else {
|
} else {
|
||||||
t = floorf(-x);
|
t = floorf(-x);
|
||||||
if (t + x <= -0.5)
|
if (t + x <= -0.5F)
|
||||||
t += 1.0;
|
t += 1;
|
||||||
return (-t);
|
return (-t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,25 +27,36 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <math.h>
|
#include <float.h>
|
||||||
|
#ifdef __i386__
|
||||||
|
#include <ieeefp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "fpmath.h"
|
||||||
|
#include "math.h"
|
||||||
|
#include "math_private.h"
|
||||||
|
|
||||||
long double
|
long double
|
||||||
roundl(long double x)
|
roundl(long double x)
|
||||||
{
|
{
|
||||||
long double t;
|
long double t;
|
||||||
|
uint16_t hx;
|
||||||
|
|
||||||
if (!isfinite(x))
|
GET_LDBL_EXPSIGN(hx, x);
|
||||||
return (x);
|
if ((hx & 0x7fff) == 0x7fff)
|
||||||
|
return (x + x);
|
||||||
|
|
||||||
if (x >= 0.0) {
|
ENTERI();
|
||||||
|
|
||||||
|
if (!(hx & 0x8000)) {
|
||||||
t = floorl(x);
|
t = floorl(x);
|
||||||
if (t - x <= -0.5)
|
if (t - x <= -0.5L)
|
||||||
t += 1.0;
|
t += 1;
|
||||||
return (t);
|
RETURNI(t);
|
||||||
} else {
|
} else {
|
||||||
t = floorl(-x);
|
t = floorl(-x);
|
||||||
if (t + x <= -0.5)
|
if (t + x <= -0.5L)
|
||||||
t += 1.0;
|
t += 1;
|
||||||
return (-t);
|
RETURNI(-t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user