1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:28:10 +00:00

LibM: optimized (branchless) copysign

This commit is contained in:
Nick Wanninger 2021-03-05 18:09:48 -06:00 committed by Andreas Kling
parent cfa100cb65
commit c3f417aa1e

View file

@ -745,12 +745,11 @@ long double nexttowardl(long double, long double) NOEXCEPT
double copysign(double x, double y)
{
if (x < 0 && y < 0)
return x;
if (x >= 0 && y < 0)
return -x;
if (x < 0 && y >= 0)
return -x;
return x;
using Extractor = FloatExtractor<decltype(x)>;
Extractor ex, ey;
ex.d = x;
ey.d = y;
ex.sign = ey.sign;
return ex.d;
}
}