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:
parent
cfa100cb65
commit
c3f417aa1e
1 changed files with 6 additions and 7 deletions
|
@ -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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue