Merge pull request #4549 from Nixitov/feat/libc-nearbyintl
feat(libc): implement nearbyintl
This commit is contained in:
commit
158cdcc9b7
|
|
@ -181,6 +181,7 @@ int APS5_VABI __isnormal_nid_postfix(double x) { return std::isnormal(x) ? 1 : 0
|
|||
int APS5_VABI __isnormalf_nid_postfix(float x) { return std::isnormal(x) ? 1 : 0; }
|
||||
int APS5_VABI __isinff_nid_postfix(float x) { return std::isinf(x) ? 1 : 0; }
|
||||
float APS5_VABI nearbyintf_nid_postfix(float x) { return std::nearbyintf(x); }
|
||||
long double APS5_VABI nearbyintl_nid_postfix(long double x) { return std::nearbyint(x); }
|
||||
|
||||
double APS5_VABI cbrt_nid_postfix(double x) { return std::cbrt(x); }
|
||||
double APS5_VABI asin_nid_postfix(double x) {
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ long double APS5_VABI log10l_nid_postfix(long double);
|
|||
long double APS5_VABI powl_nid_postfix(long double, long double);
|
||||
long double APS5_VABI ldexpl_nid_postfix(long double, int);
|
||||
long double APS5_VABI truncl_nid_postfix(long double);
|
||||
long double APS5_VABI nearbyintl_nid_postfix(long double);
|
||||
double APS5_VABI logb_nid_postfix(double);
|
||||
double APS5_VABI remainder_nid_postfix(double, double);
|
||||
}
|
||||
|
|
@ -192,6 +193,19 @@ static void CheckLongDouble() {
|
|||
Require(std::isnan(frexpl_nid_postfix(NAN, &exponent)) && exponent == 77);
|
||||
}
|
||||
|
||||
static void CheckNearbyintl() {
|
||||
std::feclearexcept(FE_ALL_EXCEPT);
|
||||
const long double zero = nearbyintl_nid_postfix(0.5L);
|
||||
Require(zero == 0.0L && !std::signbit(zero));
|
||||
Require(nearbyintl_nid_postfix(1.5L) == 2.0L && nearbyintl_nid_postfix(2.5L) == 2.0L);
|
||||
Require(nearbyintl_nid_postfix(2.7L) == 3.0L && nearbyintl_nid_postfix(-2.7L) == -3.0L);
|
||||
Require(ExtendedBits(nearbyintl_nid_postfix(-0.5L), 0, 0x8000));
|
||||
Require(nearbyintl_nid_postfix(0x1p200L) == 0x1p200L);
|
||||
Require(nearbyintl_nid_postfix(INFINITY) == INFINITY && nearbyintl_nid_postfix(-INFINITY) == -INFINITY);
|
||||
Require(std::isnan(nearbyintl_nid_postfix(NAN)));
|
||||
Require(std::fetestexcept(FE_INEXACT) == 0);
|
||||
}
|
||||
|
||||
static void CheckFmodErrno() {
|
||||
errno = 0;
|
||||
(void)fmod_nid_postfix(1.0, 0.0);
|
||||
|
|
@ -674,6 +688,7 @@ int main() {
|
|||
CheckExp2Errno();
|
||||
CheckExactOperations();
|
||||
CheckLongDouble();
|
||||
CheckNearbyintl();
|
||||
CheckAsinl();
|
||||
Require(scalbn_nid_postfix(0.75, -2) == 0.1875);
|
||||
Require(scalbnf_nid_postfix(0.75f, 4) == 12.f);
|
||||
|
|
|
|||
Loading…
Reference in New Issue