diff --git a/Libraries/LibJS/Runtime/Value.cpp b/Libraries/LibJS/Runtime/Value.cpp index fa489a65b7..889e4e18f6 100644 --- a/Libraries/LibJS/Runtime/Value.cpp +++ b/Libraries/LibJS/Runtime/Value.cpp @@ -170,6 +170,11 @@ i32 Value::to_i32() const return static_cast(to_number().as_double()); } +double Value::to_double() const +{ + return to_number().as_double(); +} + Value greater_than(Value lhs, Value rhs) { return Value(lhs.to_number().as_double() > rhs.to_number().as_double()); diff --git a/Libraries/LibJS/Runtime/Value.h b/Libraries/LibJS/Runtime/Value.h index dfdcaa8382..7a5820e6b0 100644 --- a/Libraries/LibJS/Runtime/Value.h +++ b/Libraries/LibJS/Runtime/Value.h @@ -146,6 +146,7 @@ public: bool to_boolean() const; Value to_number() const; i32 to_i32() const; + double to_double() const; Object* to_object(Heap&) const;