mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibM: optimized (branchless) copysign
This commit is contained in:
parent
cfa100cb65
commit
c3f417aa1e
Notes:
sideshowbarker
2024-07-18 21:41:01 +09:00
Author: https://github.com/nickwanninger 🔰
Commit: c3f417aa1e
Pull-request: https://github.com/SerenityOS/serenity/pull/5655
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