coderef

Math and numbersBaseline · 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).

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jul 29, 2015. Widely available since Jan 29, 2018.

Browser support

DesktopChrome
1+Supportedsince Dec 11, 2008
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1+Supportedsince Nov 9, 2004
Current: 157
Safari
1+Supportedsince Jun 23, 2003
Current: 27
MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155
Firefox Android
4+Supportedsince Mar 29, 2011
Current: 157
Safari iOS
1+Supportedsince Jun 29, 2007
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: Infinity.

Feature detection

JS · check before using
if (typeof Number !== "undefined") {
  // Number is available
}

Sub-features

Support for each part of the feature (74). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Infinity112111841
Math112111841
Math.E112111841
Math.LN10112111841
Math.LN2112111841
Math.LOG10E112111841
Math.LOG2E112111841
Math.PI112111841
Math.SQRT1_2112111841
Math.SQRT2112111841
Math.abs112111841
Math.acos112111841
Math.acosh381225838258
Math.asin112111841
Math.asinh381225838258
Math.atan112111841
Math.atan2112111841
Math.atanh381225838258
Math.cbrt381225838258
Math.ceil112111841
Show 54 more
Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Math.clz32381231738317
Math.cos112111841
Math.cosh381225838258
Math.exp112111841
Math.expm1381225838258
Math.floor112111841
Math.fround381226838268
Math.hypot381227838278
Math.imul281220728207
Math.log112111841
Math.log10381225838258
Math.log1p381225838258
Math.log2381225838258
Math.max112111841
Math.min112111841
Math.pow112111841
Math.random112111841
Math.round112111841
Math.sign381225938259
Math.sin112111841
Math.sinh381225838258
Math.sqrt112111841
Math.tan112111841
Math.tanh381225838258
Math.trunc381225838258
NaN112111841
Number112111841
Number.EPSILON341225934259
Number.MAX_SAFE_INTEGER341231934319
Number.MAX_VALUE112111841
Number.MIN_SAFE_INTEGER341231934319
Number.MIN_VALUE112111841
Number.NEGATIVE_INFINITY112111841
Number.NaN112111841
Number.Number112111841
Number.POSITIVE_INFINITY112111841
Number.isFinite191216925169
Number.isInteger341216934169
Number.isNaN251215925159
Number.isSafeInteger341232934329
Number.parseFloat341225934259
Number.parseInt341225934259
Number.toExponential112121841
Number.toFixed112121841
Number.toPrecision112121841
Number.toString112111841
Number.valueOf112111841
isNaN112111841
parseInt112111841
parseInt.leading_zero_strings_as_decimal231221625216
binary_numeric_literals411225941259
decimal_numeric_literals112111841
hexadecimal_numeric_literals112111841
octal_numeric_literals411225941259