summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-03-29 16:09:03 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-29 17:35:08 +0200
commit03c3530d86392a202694173231d35d444feb9801 (patch)
tree55cca09649b52f30087aca6f3056189018182c32
parentc698cc899d64f521b158babd9fee9b83475ac472 (diff)
downloadserenity-03c3530d86392a202694173231d35d444feb9801.zip
LibJS: Add constant properties to MathObject
-rw-r--r--Libraries/LibJS/Runtime/MathObject.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Libraries/LibJS/Runtime/MathObject.cpp b/Libraries/LibJS/Runtime/MathObject.cpp
index 8f9de1911f..611a556a6c 100644
--- a/Libraries/LibJS/Runtime/MathObject.cpp
+++ b/Libraries/LibJS/Runtime/MathObject.cpp
@@ -28,6 +28,7 @@
#include <AK/Function.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/MathObject.h>
+#include <LibM/math.h>
namespace JS {
@@ -35,6 +36,15 @@ MathObject::MathObject()
{
put_native_function("abs", abs);
put_native_function("random", random);
+
+ put("E", Value(M_E));
+ put("LN2", Value(M_LN2));
+ put("LN10", Value(M_LN10));
+ put("LOG2E", Value(log2(M_E)));
+ put("LOG10E", Value(log10(M_E)));
+ put("PI", Value(M_PI));
+ put("SQRT1_2", Value(sqrt(1 / 2)));
+ put("SQRT2", Value(sqrt(2)));
}
MathObject::~MathObject()