--- title: Math slug: Web/JavaScript/Reference/Global_Objects/Math translation_of: Web/JavaScript/Reference/Global_Objects/Math ---
{{JSRef}}

Math è un oggetto precostruito che possiede proprietà e metodi per restituire i risultati di costanti e funzioni matematiche. Math non è una funzione.

Descrizione

Diversamente dagli altri oggetti globali, Math non è un costruttore. Tutte le proprietà e i metodi di Math sono statici. Per riferirsi alla costante Pi si usa  Math.PI e per chiamare la funzione Seno si usa Math.sin(x) , dove x è l'argomento del metodo. Le costanti sono definite con la piena precisione dei numeri reali in JavaScript.

Proprietà

{{jsxref("Math.E")}}
Costante di Eulero e base dei logaritmi naturali, approssimativamente 2.718.
{{jsxref("Math.LN2")}}
Logaritmo naturale di 2, approssimativamente 0.693.
{{jsxref("Math.LN10")}}
Logaritmo naturale di 10, approssimativamente 0.693.
{{jsxref("Math.LOG2E")}}
Logaritmo a base 2 di E, approssimativamente 1.443.
{{jsxref("Math.LOG10E")}}
Logaritmo a base 10 di E, approssimativamente 1.443.
{{jsxref("Math.PI")}}
Rapporto tra la circonferenza di un cerchio ed il suo diametro, approssimativamente 3.14159.
{{jsxref("Math.SQRT1_2")}}
Radice quadrata di 1/2  ; equivale a 1 fratto la radice quadrata di 2, approsimativamente  0.707.
{{jsxref("Math.SQRT2")}}
Radice quadrata di 2, approssimativamente 1.414.

Metodi

Ricorda che le funzioni trigonometriche (sin(), cos(), tan(), asin(), acos(), atan(), atan2()) si aspettano e restituiscono gli angoli in radianti. To convert radians to degrees, divide by (Math.PI / 180), and multiply by this to convert the other way.

Ricorda che la precisione di molte delle funzioni matematiche è dipendente dall'sistema di implementazione. questo significa che browser differenti possono dare risultati diversi, e anche lo stessomotore JS su un differente sistema operativo o architettura può dare risultati discordi.

{{jsxref("Global_Objects/Math/abs", "Math.abs(x)")}}
Returns the absolute value of a number.
{{jsxref("Global_Objects/Math/acos", "Math.acos(x)")}}
Returns the arccosine of a number.
{{jsxref("Global_Objects/Math/acosh", "Math.acosh(x)")}}
Returns the hyperbolic arccosine of a number.
{{jsxref("Global_Objects/Math/asin", "Math.asin(x)")}}
Returns the arcsine of a number.
{{jsxref("Global_Objects/Math/asinh", "Math.asinh(x)")}}
Returns the hyperbolic arcsine of a number.
{{jsxref("Global_Objects/Math/atan", "Math.atan(x)")}}
Returns the arctangent of a number.
{{jsxref("Global_Objects/Math/atanh", "Math.atanh(x)")}}
Returns the hyperbolic arctangent of a number.
{{jsxref("Global_Objects/Math/atan2", "Math.atan2(y, x)")}}
Returns the arctangent of the quotient of its arguments.
{{jsxref("Global_Objects/Math/cbrt", "Math.cbrt(x)")}}
Returns the cube root of a number.
{{jsxref("Global_Objects/Math/ceil", "Math.ceil(x)")}}
Returns the smallest integer greater than or equal to a number.
{{jsxref("Global_Objects/Math/clz32", "Math.clz32(x)")}}
Returns the number of leading zeroes of a 32-bit integer.
{{jsxref("Global_Objects/Math/cos", "Math.cos(x)")}}
Returns the cosine of a number.
{{jsxref("Global_Objects/Math/cosh", "Math.cosh(x)")}}
Returns the hyperbolic cosine of a number.
{{jsxref("Global_Objects/Math/exp", "Math.exp(x)")}}
Returns Ex, where x is the argument, and E is Euler's constant (2.718…), the base of the natural logarithm.
{{jsxref("Global_Objects/Math/expm1", "Math.expm1(x)")}}
Returns subtracting 1 from exp(x).
{{jsxref("Global_Objects/Math/floor", "Math.floor(x)")}}
Returns the largest integer less than or equal to a number.
{{jsxref("Global_Objects/Math/fround", "Math.fround(x)")}}
Returns the nearest single precision float representation of a number.
{{jsxref("Global_Objects/Math/hypot", "Math.hypot([x[, y[, …]]])")}}
Returns the square root of the sum of squares of its arguments.
{{jsxref("Global_Objects/Math/imul", "Math.imul(x, y)")}}
Returns the result of a 32-bit integer multiplication.
{{jsxref("Global_Objects/Math/log", "Math.log(x)")}}
Returns the natural logarithm (loge, also ln) of a number.
{{jsxref("Global_Objects/Math/log1p", "Math.log1p(x)")}}
Returns the natural logarithm of 1 + x (loge, also ln) of a number.
{{jsxref("Global_Objects/Math/log10", "Math.log10(x)")}}
Returns the base 10 logarithm of a number.
{{jsxref("Global_Objects/Math/log2", "Math.log2(x)")}}
Returns the base 2 logarithm of a number.
{{jsxref("Global_Objects/Math/max", "Math.max([x[, y[, …]]])")}}
Returns the largest of zero or more numbers.
{{jsxref("Global_Objects/Math/min", "Math.min([x[, y[, …]]])")}}
Returns the smallest of zero or more numbers.
{{jsxref("Global_Objects/Math/pow", "Math.pow(x, y)")}}
Returns base to the exponent power, that is, baseexponent.
{{jsxref("Global_Objects/Math/random", "Math.random()")}}
Returns a pseudo-random number between 0 and 1.
{{jsxref("Global_Objects/Math/round", "Math.round(x)")}}
Returns the value of a number rounded to the nearest integer.
{{jsxref("Global_Objects/Math/sign", "Math.sign(x)")}}
Returns the sign of the x, indicating whether x is positive, negative or zero.
{{jsxref("Global_Objects/Math/sin", "Math.sin(x)")}}
Returns the sine of a number.
{{jsxref("Global_Objects/Math/sinh", "Math.sinh(x)")}}
Returns the hyperbolic sine of a number.
{{jsxref("Global_Objects/Math/sqrt", "Math.sqrt(x)")}}
Returns the positive square root of a number.
{{jsxref("Global_Objects/Math/tan", "Math.tan(x)")}}
Returns the tangent of a number.
{{jsxref("Global_Objects/Math/tanh", "Math.tanh(x)")}}
Returns the hyperbolic tangent of a number.
Math.toSource() {{non-standard_inline}}
Returns the string "Math".
{{jsxref("Global_Objects/Math/trunc", "Math.trunc(x)")}}
Returns the integral part of the number x, removing any fractional digits.

Specifications

Specification Status Comment
{{SpecName('ES1')}} {{Spec2('ES1')}} Initial definition. Implemented in JavaScript 1.1.
{{SpecName('ES5.1', '#sec-15.8', 'Math')}} {{Spec2('ES5.1')}}  
{{SpecName('ES6', '#sec-math-object', 'Math')}} {{Spec2('ES6')}} New methods {{jsxref("Math.log10()", "log10()")}}, {{jsxref("Math.log2()", "log2()")}}, {{jsxref("Math.log1p()", "log1p()")}}, {{jsxref("Math.expm1()", "expm1()")}}, {{jsxref("Math.cosh()", "cosh()")}}, {{jsxref("Math.sinh()", "sinh()")}}, {{jsxref("Math.tanh()", "tanh()")}}, {{jsxref("Math.acosh()", "acosh()")}}, {{jsxref("Math.asinh()", "asinh()")}}, {{jsxref("Math.atanh()", "atanh()")}}, {{jsxref("Math.hypot()", "hypot()")}}, {{jsxref("Math.trunc()", "trunc()")}}, {{jsxref("Math.sign()", "sign()")}}, {{jsxref("Math.imul()", "imul()")}}, {{jsxref("Math.fround()", "fround()")}}, {{jsxref("Math.cbrt()", "cbrt()")}} and {{jsxref("Math.clz32()", "clz32()")}} added.
{{SpecName('ESDraft', '#sec-math-object', 'Math')}} {{Spec2('ESDraft')}}  

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}

See also