title: Math Extensions
stage: 1
location: https://github.com/rwaldron/proposal-math-extensions
copyright: false
contributors: Rick Waldron

Well-Known Intrinsic Objects

Additions

Intrinsic Name Global Name ECMAScript Language Association
%Math_max% `Math.max` The `Math.max` function ()
%Math_min% `Math.min` The `Math.min` function ()

Math.clamp ( _x_, _lower_, _upper_ )

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

1. If any argument is *NaN*, return *NaN*. 1. Let _max_ be %Math_max%(_x_, _lower_). 1. Let _min_ be %Math_min%(_max_, _upper_). 1. Return _min_.

Math.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*. 1. If _x_ is one of *+∞*, *-∞*, return _x_. 1. Return (_x_ − _inLow_) × (_outHigh_ − _outLow_) ÷ (_inHigh_ − _inLow_) + _outLow_.

Math.radians ( _degrees_ )

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

1. If _degrees_ is one of *NaN*, *+∞*, *-∞*, return _degrees_. 1. Let _radians_ be (_degrees_ × `Math.DEG_PER_RAD`). 1. Return _radians_.

Math.degrees ( _radians_ )

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

1. If _radians_ is one of *NaN*, *+∞*, *-∞*, return _radians_. 1. Let _degrees_ be (_radians_ × `Math.RAD_PER_DEG`). 1. Return _degrees_.

Math.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* }.

Math.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* }.