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

LibJS: Implement exponentiation (** operator)

This commit is contained in:
Linus Groh 2020-04-05 13:40:00 +01:00 committed by Andreas Kling
parent eafd3dbaf8
commit 0403845d3e
7 changed files with 48 additions and 1 deletions

View file

@ -35,6 +35,7 @@
#include <LibJS/Runtime/PrimitiveString.h>
#include <LibJS/Runtime/StringObject.h>
#include <LibJS/Runtime/Value.h>
#include <math.h>
namespace JS {
@ -268,6 +269,11 @@ Value mod(Value lhs, Value rhs)
return Value(index - trunc * period);
}
Value exp(Value lhs, Value rhs)
{
return Value(pow(lhs.to_number().as_double(), rhs.to_number().as_double()));
}
Value typed_eq(Value lhs, Value rhs)
{
if (rhs.type() != lhs.type())