mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 20:25:08 +00:00
LibWasm: Implement fx.nearest using nearbyint() instead of round()
This instruction wants RoundingMode::ToEven, so let's use the correct function.
This commit is contained in:
parent
e93c740df5
commit
2c7e2e351a
2 changed files with 5 additions and 5 deletions
|
@ -824,7 +824,7 @@ void BytecodeInterpreter::interpret(Configuration& configuration, InstructionPoi
|
||||||
case Instructions::f32_trunc.value():
|
case Instructions::f32_trunc.value():
|
||||||
return unary_operation<float, float, Operators::Truncate>(configuration);
|
return unary_operation<float, float, Operators::Truncate>(configuration);
|
||||||
case Instructions::f32_nearest.value():
|
case Instructions::f32_nearest.value():
|
||||||
return unary_operation<float, float, Operators::Round>(configuration);
|
return unary_operation<float, float, Operators::NearbyIntegral>(configuration);
|
||||||
case Instructions::f32_sqrt.value():
|
case Instructions::f32_sqrt.value():
|
||||||
return unary_operation<float, float, Operators::SquareRoot>(configuration);
|
return unary_operation<float, float, Operators::SquareRoot>(configuration);
|
||||||
case Instructions::f32_add.value():
|
case Instructions::f32_add.value():
|
||||||
|
@ -852,7 +852,7 @@ void BytecodeInterpreter::interpret(Configuration& configuration, InstructionPoi
|
||||||
case Instructions::f64_trunc.value():
|
case Instructions::f64_trunc.value():
|
||||||
return unary_operation<double, double, Operators::Truncate>(configuration);
|
return unary_operation<double, double, Operators::Truncate>(configuration);
|
||||||
case Instructions::f64_nearest.value():
|
case Instructions::f64_nearest.value():
|
||||||
return unary_operation<double, double, Operators::Round>(configuration);
|
return unary_operation<double, double, Operators::NearbyIntegral>(configuration);
|
||||||
case Instructions::f64_sqrt.value():
|
case Instructions::f64_sqrt.value():
|
||||||
return unary_operation<double, double, Operators::SquareRoot>(configuration);
|
return unary_operation<double, double, Operators::SquareRoot>(configuration);
|
||||||
case Instructions::f64_add.value():
|
case Instructions::f64_add.value():
|
||||||
|
|
|
@ -271,14 +271,14 @@ struct Truncate {
|
||||||
|
|
||||||
static StringView name() { return "truncate"; }
|
static StringView name() { return "truncate"; }
|
||||||
};
|
};
|
||||||
struct Round {
|
struct NearbyIntegral {
|
||||||
template<typename Lhs>
|
template<typename Lhs>
|
||||||
auto operator()(Lhs lhs) const
|
auto operator()(Lhs lhs) const
|
||||||
{
|
{
|
||||||
if constexpr (IsSame<Lhs, float>)
|
if constexpr (IsSame<Lhs, float>)
|
||||||
return roundf(lhs);
|
return nearbyintf(lhs);
|
||||||
else if constexpr (IsSame<Lhs, double>)
|
else if constexpr (IsSame<Lhs, double>)
|
||||||
return round(lhs);
|
return nearbyint(lhs);
|
||||||
else
|
else
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue