mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-31 13:48:25 +00:00
LibWasm: Fix comparisons between 0.0 and -0.0
According to the spec, -0.0 < 0.0.
This commit is contained in:
@@ -329,14 +329,12 @@ struct Minimum {
|
|||||||
auto operator()(Lhs lhs, Rhs rhs) const
|
auto operator()(Lhs lhs, Rhs rhs) const
|
||||||
{
|
{
|
||||||
if constexpr (IsFloatingPoint<Lhs> || IsFloatingPoint<Rhs>) {
|
if constexpr (IsFloatingPoint<Lhs> || IsFloatingPoint<Rhs>) {
|
||||||
if (isnan(lhs))
|
if (isnan(lhs) || isnan(rhs)) {
|
||||||
return lhs;
|
return isnan(lhs) ? lhs : rhs;
|
||||||
if (isnan(rhs))
|
}
|
||||||
return rhs;
|
if (lhs == 0 && rhs == 0) {
|
||||||
if (isinf(lhs))
|
return signbit(lhs) ? lhs : rhs;
|
||||||
return lhs > 0 ? rhs : lhs;
|
}
|
||||||
if (isinf(rhs))
|
|
||||||
return rhs > 0 ? lhs : rhs;
|
|
||||||
}
|
}
|
||||||
return min(lhs, rhs);
|
return min(lhs, rhs);
|
||||||
}
|
}
|
||||||
@@ -349,14 +347,12 @@ struct Maximum {
|
|||||||
auto operator()(Lhs lhs, Rhs rhs) const
|
auto operator()(Lhs lhs, Rhs rhs) const
|
||||||
{
|
{
|
||||||
if constexpr (IsFloatingPoint<Lhs> || IsFloatingPoint<Rhs>) {
|
if constexpr (IsFloatingPoint<Lhs> || IsFloatingPoint<Rhs>) {
|
||||||
if (isnan(lhs))
|
if (isnan(lhs) || isnan(rhs)) {
|
||||||
return lhs;
|
return isnan(lhs) ? lhs : rhs;
|
||||||
if (isnan(rhs))
|
}
|
||||||
return rhs;
|
if (lhs == 0 && rhs == 0) {
|
||||||
if (isinf(lhs))
|
return signbit(lhs) ? rhs : lhs;
|
||||||
return lhs > 0 ? lhs : rhs;
|
}
|
||||||
if (isinf(rhs))
|
|
||||||
return rhs > 0 ? rhs : lhs;
|
|
||||||
}
|
}
|
||||||
return max(lhs, rhs);
|
return max(lhs, rhs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user