MCPcopy Create free account
hub / github.com/dynjs/dynjs / Math

Method Math

src/main/java/org/dynjs/runtime/builtins/Math.java:26–62  ·  view source on GitHub ↗
(final GlobalContext globalContext)

Source from the content-addressed store, hash-verified

24public class Math extends DynObject {
25
26 public Math(final GlobalContext globalContext) {
27 super(globalContext);
28
29 // Math properties 15.8.1
30 defineReadOnlyProperty(globalContext, "E", java.lang.Math.E); // 15.8.1.1
31 defineReadOnlyProperty(globalContext, "LN10", java.lang.Math.log(10)); // 15.8.1.2
32 defineReadOnlyProperty(globalContext, "LN2", java.lang.Math.log(2)); // 15.8.1.3
33 defineReadOnlyProperty(globalContext, "LOG2E", java.lang.Math.log(java.lang.Math.E) / java.lang.Math.log(2)); // 15.8.1.4
34 defineReadOnlyProperty(globalContext, "LOG10E", java.lang.Math.log10(java.lang.Math.E)); // 15.8.1.5
35 defineReadOnlyProperty(globalContext, "PI", java.lang.Math.PI); // 15.8.1.6
36 defineReadOnlyProperty(globalContext, "SQRT1_2", java.lang.Math.sqrt(0.5f)); // 15.8.1.7
37 defineReadOnlyProperty(globalContext, "SQRT2", java.lang.Math.sqrt(2.0f)); // 15.8.1.8
38
39 defineReadOnlyProperty(globalContext, "NaN", Double.NaN );
40
41 // Math functions 15.8.2
42 defineNonEnumerableProperty(globalContext, "abs", new Abs(globalContext)); // 15.8.2.1
43 defineNonEnumerableProperty(globalContext, "acos", new Acos(globalContext)); // 15.8.2.2
44 defineNonEnumerableProperty(globalContext, "asin", new Asin(globalContext)); // 15.8.2.3
45 defineNonEnumerableProperty(globalContext, "atan", new Atan(globalContext)); // 15.8.2.4
46 defineNonEnumerableProperty(globalContext, "atan2", new Atan2(globalContext)); // 15.8.2.5
47 defineNonEnumerableProperty(globalContext, "ceil", new Ceil(globalContext)); // 15.8.2.6
48 defineNonEnumerableProperty(globalContext, "cos", new Cos(globalContext)); // 15.8.2.7
49 defineNonEnumerableProperty(globalContext, "exp", new Exp(globalContext)); // 15.8.2.8
50 defineNonEnumerableProperty(globalContext, "floor", new Floor(globalContext)); // 15.8.2.9
51 defineNonEnumerableProperty(globalContext, "log", new Log(globalContext)); // 15.8.2.10
52 defineNonEnumerableProperty(globalContext, "max", new Max(globalContext)); // 15.8.2.11
53 defineNonEnumerableProperty(globalContext, "min", new Min(globalContext)); // 15.8.2.12
54 defineNonEnumerableProperty(globalContext, "pow", new Pow(globalContext)); // 15.8.2.13
55 defineNonEnumerableProperty(globalContext, "random", new Random(globalContext)); // 15.8.2.14
56 defineNonEnumerableProperty(globalContext, "round", new Round(globalContext)); // 15.8.2.15
57 defineNonEnumerableProperty(globalContext, "sin", new Sin(globalContext)); // 15.8.2.16
58 defineNonEnumerableProperty(globalContext, "sqrt", new Sqrt(globalContext)); // 15.8.2.17
59 defineNonEnumerableProperty(globalContext, "tan", new Tan(globalContext)); // 15.8.2.18
60
61 setClassName( "Math" );
62 }
63
64 public static Object coerceLongIfPossible(double d) {
65 if (Double.isInfinite(d) || Double.isNaN(d) || (d - java.lang.Math.ceil(d) != 0) || d > Long.MAX_VALUE)

Callers

nothing calls this directly

Calls 4

setClassNameMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected