1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 19:37:34 +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) double copysign(double x, double y)
{ {
if (x < 0 && y < 0) using Extractor = FloatExtractor<decltype(x)>;
return x; Extractor ex, ey;
if (x >= 0 && y < 0) ex.d = x;
return -x; ey.d = y;
if (x < 0 && y >= 0) ex.sign = ey.sign;
return -x; return ex.d;
return x;
} }
} }