This is the formal specification for a proposed extension
of the Math
JavaScript
This section augments the original Numeric Types clause.
ECMAScript has two built-in numeric types: Number and BigInt. In this specification, every numeric type T contains a multiplicative identity value denoted T::unit. The specification types also have the following
Invocation Synopsis | Example source | Invoked by the Evaluation semantics of ... | Result |
---|---|---|---|
T::bitwiseOR(x, y) |
x | y
|
|
T |
T:: |
Math.abs(x)
|
T | |
T::clz32(x) |
Math.clz32(x)
|
T | |
T::sign(x) |
Math.sign(x)
|
T | |
T::toString(x) |
String(x)
|
Many expressions and built-in functions, via |
String |
The abstract operation Number::abs takes argument x (a Number). It performs the following steps when called:
The abstract operation Number::clz32 takes argument x (a Number). It performs the following steps when called:
If n is
The abstract operation Number::sign takes argument x (a Number). It performs the following steps when called:
The abstract operation BigInt::abs takes argument x (a BigInt). It performs the following steps when called:
The abstract operation BigInt::clz32 takes argument x (a BigInt). It performs the following steps when called:
The abstract operation BigInt::sign takes argument x (a BigInt). It performs the following steps when called:
This section augments the original Function Properties of the Math Object clause.
Returns the absolute value of x; the result has the same magnitude as x but has positive sign.
When the Math.abs
method is called with argument x, the following steps are taken:
When the Math.clz32
method is called with argument x, the following steps are taken:
If n is
Given zero or more arguments, calls
When the Math.max
method is called with zero or more arguments which form the rest parameter ...args, the following steps are taken:
The comparison of values to determine the largest value is done using the IsLessThan algorithm except that
The max
method is
Given zero or more arguments, calls
When the Math.min
method is called with zero or more arguments which form the rest parameter ...args, the following steps are taken:
The comparison of values to determine the largest value is done using the IsLessThan algorithm except that
The min
method is
When the Math.pow
method is called with arguments base and exponent, the following steps are taken:
Returns the sign of x, indicating whether x is positive, negative, or zero.
When the Math.sign
method is called with argument x, the following steps are taken:
© 2021 J. S. Choi, Ecma International
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.