Math and numbers
Widely available
The number type (and Number
object) represents floating-point numbers, such as 42 or -4.201, while the Math
API contains mathematical functions and constants. JavaScript can also represent boundless negative and positive values as Infinity
or not-a-number as NaN
(as in 0 * Infinity
).
Compatibility
- Chrome 1 Released on 2008-12-11
- Chrome Android 18 Released on 2012-06-27
- Edge 12 Released on 2015-07-29
- Firefox 1 Released on 2004-11-09
- Firefox for Android 4 Released on 2011-03-29
- Safari 1 Released on 2003-06-23
- Safari on iOS 1 Released on 2007-06-29
MDN docs
- Infinity global object
- Math global object
- Math.E
- Math.LN10
- Math.LN2
- Math.LOG10E
- Math.LOG2E
- Math.PI
- Math.SQRT1_2
- Math.SQRT2
- Math.abs
- Math.acos
- Math.acosh
- Math.asin
- Math.asinh
- Math.atan
- Math.atan2
- Math.atanh
- Math.cbrt
- Math.ceil
- Math.clz32
- Math.cos
- Math.cosh
- Math.exp
- Math.expm1
- Math.floor
- Math.fround
- Math.hypot
- Math.imul
- Math.log
- Math.log10
- Math.log1p
- Math.log2
- Math.max
- Math.min
- Math.pow
- Math.random
- Math.round
- Math.sign
- Math.sin
- Math.sinh
- Math.sqrt
- Math.tan
- Math.tanh
- Math.trunc
- NaN global object
- Number global object
- Number.EPSILON
- Number.MAX_SAFE_INTEGER
- Number.MAX_VALUE
- Number.MIN_SAFE_INTEGER
- Number.MIN_VALUE
- Number.NEGATIVE_INFINITY
- Number.NaN
- Number.Number
- Number.POSITIVE_INFINITY
- Number.isFinite
- Number.isInteger
- Number.isNaN
- Number.isSafeInteger
- Number.parseFloat
- Number.parseInt
- Number.toExponential
- Number.toFixed
- Number.toPrecision
- Number.toString
- Number.valueOf
- isNaN global object
- parseInt global object
- Reference/Lexical_grammar#Binary
- Reference/Lexical_grammar#Decimal
- Reference/Lexical_grammar#Hexadecimal
- Reference/Lexical_grammar#Octal
Specifications
- ECMAScript Language Specification, from TC39 (Ecma International).
BCD data
- javascript.builtins.Infinity
- javascript.builtins.Math
- javascript.builtins.Math.E
- javascript.builtins.Math.LN10
- javascript.builtins.Math.LN2
- javascript.builtins.Math.LOG10E
- javascript.builtins.Math.LOG2E
- javascript.builtins.Math.PI
- javascript.builtins.Math.SQRT1_2
- javascript.builtins.Math.SQRT2
- javascript.builtins.Math.abs
- javascript.builtins.Math.acos
- javascript.builtins.Math.acosh
- javascript.builtins.Math.asin
- javascript.builtins.Math.asinh
- javascript.builtins.Math.atan
- javascript.builtins.Math.atan2
- javascript.builtins.Math.atanh
- javascript.builtins.Math.cbrt
- javascript.builtins.Math.ceil
- javascript.builtins.Math.clz32
- javascript.builtins.Math.cos
- javascript.builtins.Math.cosh
- javascript.builtins.Math.exp
- javascript.builtins.Math.expm1
- javascript.builtins.Math.floor
- javascript.builtins.Math.fround
- javascript.builtins.Math.hypot
- javascript.builtins.Math.imul
- javascript.builtins.Math.log
- javascript.builtins.Math.log10
- javascript.builtins.Math.log1p
- javascript.builtins.Math.log2
- javascript.builtins.Math.max
- javascript.builtins.Math.min
- javascript.builtins.Math.pow
- javascript.builtins.Math.random
- javascript.builtins.Math.round
- javascript.builtins.Math.sign
- javascript.builtins.Math.sin
- javascript.builtins.Math.sinh
- javascript.builtins.Math.sqrt
- javascript.builtins.Math.tan
- javascript.builtins.Math.tanh
- javascript.builtins.Math.trunc
- javascript.builtins.NaN
- javascript.builtins.Number
- javascript.builtins.Number.EPSILON
- javascript.builtins.Number.MAX_SAFE_INTEGER
- javascript.builtins.Number.MAX_VALUE
- javascript.builtins.Number.MIN_SAFE_INTEGER
- javascript.builtins.Number.MIN_VALUE
- javascript.builtins.Number.NEGATIVE_INFINITY
- javascript.builtins.Number.NaN
- javascript.builtins.Number.Number
- javascript.builtins.Number.POSITIVE_INFINITY
- javascript.builtins.Number.isFinite
- javascript.builtins.Number.isInteger
- javascript.builtins.Number.isNaN
- javascript.builtins.Number.isSafeInteger
- javascript.builtins.Number.parseFloat
- javascript.builtins.Number.parseInt
- javascript.builtins.Number.toExponential
- javascript.builtins.Number.toFixed
- javascript.builtins.Number.toPrecision
- javascript.builtins.Number.toString
- javascript.builtins.Number.valueOf
- javascript.builtins.isNaN
- javascript.builtins.parseInt
- javascript.grammar.binary_numeric_literals
- javascript.grammar.decimal_numeric_literals
- javascript.grammar.hexadecimal_numeric_literals
- javascript.grammar.octal_numeric_literals