1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:27:43 +00:00

LibJS: Add basic support for modulo (%) in binary expressions

This commit is contained in:
Andreas Kling 2020-04-04 21:17:34 +02:00
parent 9c8363bb5f
commit 644ff1bbfd
6 changed files with 25 additions and 0 deletions

View file

@ -239,6 +239,12 @@ Value div(Value lhs, Value rhs)
return Value(lhs.to_number().as_double() / rhs.to_number().as_double());
}
Value mod(Value lhs, Value rhs)
{
// FIXME: It seems like JavaScript should allow modulo for doubles as well(?)
return Value(lhs.to_i32() % rhs.to_i32());
}
Value typed_eq(Value lhs, Value rhs)
{
if (rhs.type() != lhs.type())