Stage 1 Draft / July 28, 2016

Math Extensions

1Well-Known Intrinsic Objects#

Additions

Table 1: Well-known Intrinsic Objects
Intrinsic Name Global Name ECMAScript Language Association
%Math_max% Math.max The Math.max function ( 20.2.2.24)
%Math_min% Math.min The Math.min function ( 20.2.2.25)

2Math.clamp ( x, lower, upper )#

When the clamp function is called, the following steps are taken:

  1. If any argument is NaN, return NaN.
  2. Let max be %Math_max%(x, lower).
  3. Let min be %Math_min%(max, upper).
  4. Return min.

3Math.scale ( x, inLow, inHigh, outLow, outHigh )#

When the scale function is called, the following steps are taken:

  1. If any argument is NaN, return NaN.
  2. If x is one of +∞, -∞, return x.
  3. Return (xinLow) × (outHighoutLow) ÷ (inHighinLow) + outLow.

4Math.radians ( degrees )#

When the radians function is called, the following steps are taken:

  1. If degrees is one of NaN, +∞, -∞, return degrees.
  2. Let radians be (degrees × Math.DEG_PER_RAD).
  3. Return radians.

5Math.degrees ( radians )#

When the degrees function is called, the following steps are taken:

  1. If radians is one of NaN, +∞, -∞, return radians.
  2. Let degrees be (radians × Math.RAD_PER_DEG).
  3. Return degrees.

6Math.RAD_PER_DEG#

The Number value of Math.RAD_PER_DEG is approximately 57.29577951308232.

180 = 57.29577951308232
π

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

7Math.DEG_PER_RAD#

The Number value of Math.DEG_PER_RAD is approximately 0.0174532925199432.

π = 0.0174532925199432
180

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.