feat(libc): implement floor
This commit is contained in:
parent
584cc4c571
commit
f8e2c6497b
|
|
@ -200,6 +200,7 @@ double APS5_VABI fabs_nid_postfix(double x) { return std::fabs(x); }
|
|||
int APS5_VABI abs_nid_postfix(int x) { return x < 0 ? static_cast<int>(0u - static_cast<unsigned>(x)) : x; }
|
||||
double APS5_VABI trunc_nid_postfix(double x) { return std::trunc(x); }
|
||||
double APS5_VABI ceil_nid_postfix(double x) { return std::ceil(x); }
|
||||
double APS5_VABI floor_nid_postfix(double x) { return std::floor(x); }
|
||||
double APS5_VABI fma_nid_postfix(double x, double y, double z) { return std::fma(x, y, z); }
|
||||
long double APS5_VABI acosl_nid_postfix(long double x) { return std::acos(x); }
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ double APS5_VABI fabs_nid_postfix(double);
|
|||
int APS5_VABI abs_nid_postfix(int);
|
||||
double APS5_VABI trunc_nid_postfix(double);
|
||||
double APS5_VABI ceil_nid_postfix(double);
|
||||
double APS5_VABI floor_nid_postfix(double);
|
||||
double APS5_VABI nearbyint_nid_postfix(double);
|
||||
double APS5_VABI fma_nid_postfix(double, double, double);
|
||||
long double APS5_VABI acosl_nid_postfix(long double);
|
||||
|
|
@ -146,6 +147,15 @@ static void CheckExactOperations() {
|
|||
Require(std::fesetround(FE_DOWNWARD) == 0);
|
||||
const bool ceilIgnoresRounding = ceil_nid_postfix(2.2) == 3. && ceil_nid_postfix(-2.7) == -2.;
|
||||
Require(std::fesetround(FE_TONEAREST) == 0 && ceilIgnoresRounding);
|
||||
Require(floor_nid_postfix(2.7) == 2. && floor_nid_postfix(-2.2) == -3. && floor_nid_postfix(5.) == 5.);
|
||||
Require(std::bit_cast<std::uint64_t>(floor_nid_postfix(-0.5)) == 0xbff0000000000000ull);
|
||||
Require(std::bit_cast<std::uint64_t>(floor_nid_postfix(-0.)) == 0x8000000000000000ull && floor_nid_postfix(-0x1p-1074) == -1.);
|
||||
Require(std::bit_cast<std::uint64_t>(floor_nid_postfix(0.5)) == 0);
|
||||
Require(floor_nid_postfix(4503599627370495.5) == 4503599627370495. && floor_nid_postfix(-1e300) == -1e300);
|
||||
Require(floor_nid_postfix(INFINITY) == INFINITY && floor_nid_postfix(-INFINITY) == -INFINITY && std::isnan(floor_nid_postfix(nan)));
|
||||
Require(std::fesetround(FE_UPWARD) == 0);
|
||||
const bool floorIgnoresRounding = floor_nid_postfix(2.7) == 2. && floor_nid_postfix(-2.2) == -3.;
|
||||
Require(std::fesetround(FE_TONEAREST) == 0 && floorIgnoresRounding);
|
||||
Require(fma_nid_postfix(2., 3., 4.) == 10.);
|
||||
volatile double tenth = 0.1;
|
||||
Require(fma_nid_postfix(tenth, 10., -1.) == 0x1p-54);
|
||||
|
|
|
|||
Loading…
Reference in New Issue