1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:37:35 +00:00

LibM: Implement copysign for float and long double

This commit is contained in:
Mițca Dumitru 2021-03-07 23:14:46 +02:00 committed by Andreas Kling
parent 87b61b0eef
commit b274120b3c
2 changed files with 26 additions and 8 deletions

View file

@ -289,6 +289,17 @@ static FloatT internal_scalbn(FloatT x, int exponent) NOEXCEPT
return extractor.d;
}
template<typename FloatT>
static FloatT internal_copysign(FloatT x, FloatT y) NOEXCEPT
{
using Extractor = FloatExtractor<FloatT>;
Extractor ex, ey;
ex.d = x;
ey.d = y;
ex.sign = ey.sign;
return ex.d;
}
extern "C" {
double trunc(double x) NOEXCEPT
@ -845,14 +856,19 @@ long double nexttowardl(long double, long double) NOEXCEPT
TODO();
}
double copysign(double x, double y)
float copysignf(float x, float y) NOEXCEPT
{
using Extractor = FloatExtractor<decltype(x)>;
Extractor ex, ey;
ex.d = x;
ey.d = y;
ex.sign = ey.sign;
return ex.d;
return internal_copysign(x, y);
}
double copysign(double x, double y) NOEXCEPT
{
return internal_copysign(x, y);
}
long double copysignl(long double x, long double y) NOEXCEPT
{
return internal_copysign(x, y);
}
float scalbnf(float x, int exponent) NOEXCEPT