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:
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue