# Math

• Enlace amigable (slug) de la revisión: Referencia_de_JavaScript_1.5/Objetos_globales/Math
• Título de la revisión: Math
• Id de la revisión: 182109
• ¿Es la revisión actual? No
• Comentario robot Añadido: [[en:Core JavaScript 1.5 Reference:Global Objects:Math]] <<langbot>>

## Contenido de la revisión

### Summary

Core Object

A built-in object that has properties and methods for mathematical constants and functions. For example, the `Math` object's PI property has the value of pi.

### Created by

The `Math` object is a top-level, predefined JavaScript object. You can automatically access it without using a constructor or calling a method.

### Description

All properties and methods of `Math` are static. You refer to the constant pi as `Math.PI` and you call the sine function as `Math.sin(x)`, where `x` is the method's argument. Constants are defined with the full precision of real numbers in JavaScript.

It is often convenient to use the with statement when a section of code uses several `Math` constants and methods, so you don't have to type "Math" repeatedly. For example,

```with (Math) {
a = PI * r*r
y = r*sin(theta)
x = r*cos(theta)
}
```

### Properties

E: Euler's constant and the base of natural logarithms, approximately 2.718.

LN2: Natural logarithm of 2, approximately 0.693.

LN10: Natural logarithm of 10, approximately 2.302.

LOG2E: Base 2 logarithm of E, approximately 1.442.

LOG10E: Base 10 logarithm of E, approximately 0.434.

PI: Ratio of the circumference of a circle to its diameter, approximately 3.14159.

SQRT1_2: Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707.

SQRT2: Square root of 2, approximately 1.414.

### Methods

abs: Returns the absolute value of a number.

acos: Returns the arccosine (in radians) of a number.

asin: Returns the arcsine (in radians) of a number.

atan: Returns the arctangent (in radians) of a number.

atan2: Returns the arctangent of the quotient of its arguments.

ceil: Returns the smallest integer greater than or equal to a number.

cos: Returns the cosine of a number.

exp: Returns Enumber, where number is the argument, and E is Euler's constant, the base of the natural logarithms.

floor: Returns the largest integer less than or equal to a number.

log: Returns the natural logarithm (base E) of a number.

max: Returns the largest of zero or more numbers.

min: Returns the smallest of zero or more numbers.

pow: Returns base to the exponent power, that is, base exponent.

random: Returns a pseudo-random number between 0 and 1.

round: Returns the value of a number rounded to the nearest integer.

sin: Returns the sine of a number.

sqrt: Returns the square root of a number.

tan: Returns the tangent of a number.

{{ wiki.languages( { "en": "en/Core_JavaScript_1.5_Reference/Global_Objects/Math", "fr": "fr/R\u00e9f\u00e9rence_de_JavaScript_1.5_Core/Objets_globaux/Math", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/Math" } ) }}

## Fuente de la revisión

```<p>
</p>
<h3 name="Summary"> Summary </h3>
<p><b>Core Object</b>
</p><p>A built-in object that has properties and methods for mathematical constants and functions. For example, the <code>Math</code> object's <a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/PI">PI</a> property has the value of pi.
</p>
<h3 name="Created_by"> Created by </h3>
<p>The <code>Math</code> object is a top-level, predefined JavaScript object. You can automatically access it without using a constructor or calling a method.
</p>
<h3 name="Description"> Description </h3>
<p>All properties and methods of <code>Math</code> are static. You refer to the constant pi as <code>Math.PI</code> and you call the sine function as <code>Math.sin(x)</code>, where <code>x</code> is the method's argument. Constants are defined with the full precision of real numbers in JavaScript.
</p><p>It is often convenient to use the <a href="es/Core_JavaScript_1.5_Reference/Statements/with">with</a> statement when a section of code uses several <code>Math</code> constants and methods, so you don't have to type "Math" repeatedly. For example,
</p>
<pre>with (Math) {
a = PI * r*r
y = r*sin(theta)
x = r*cos(theta)
}
</pre>
<h3 name="Properties"> Properties </h3>
<p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/E">E</a>: Euler's constant and the base of natural logarithms, approximately 2.718.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/LN2">LN2</a>: Natural logarithm of 2, approximately 0.693.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/LN10">LN10</a>: Natural logarithm of 10, approximately 2.302.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/LOG2E">LOG2E</a>: Base 2 logarithm of E, approximately 1.442.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/LOG10E">LOG10E</a>: Base 10 logarithm of E, approximately 0.434.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/PI">PI</a>: Ratio of the circumference of a circle to its diameter, approximately 3.14159.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/SQRT1_2">SQRT1_2</a>: Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/SQRT2">SQRT2</a>: Square root of 2, approximately 1.414.
</p>
<h3 name="Methods"> Methods </h3>
<p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/abs">abs</a>: Returns the absolute value of a number.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/acos">acos</a>: Returns the arccosine (in radians) of a number.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/asin">asin</a>: Returns the arcsine (in radians) of a number.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/atan">atan</a>: Returns the arctangent (in radians) of a number.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/atan2">atan2</a>: Returns the arctangent of the quotient of its arguments.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/ceil">ceil</a>: Returns the smallest integer greater than or equal to a number.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/cos">cos</a>: Returns the cosine of a number.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/exp">exp</a>: Returns Enumber, where number is the argument, and E is Euler's constant, the base of the natural logarithms.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/floor">floor</a>: Returns the largest integer less than or equal to a number.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/log">log</a>: Returns the natural logarithm (base E) of a number.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/max">max</a>: Returns the largest of zero or more numbers.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/min">min</a>: Returns the smallest of zero or more numbers.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/pow">pow</a>: Returns base to the exponent power, that is, base exponent.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/random">random</a>: Returns a pseudo-random number between 0 and 1.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/round">round</a>: Returns the value of a number rounded to the nearest integer.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/sin">sin</a>: Returns the sine of a number.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/sqrt">sqrt</a>: Returns the square root of a number.
</p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Math/tan">tan</a>: Returns the tangent of a number.
</p><p><br>
</p>
<div class="noinclude">
</div>
{{ wiki.languages( { "en": "en/Core_JavaScript_1.5_Reference/Global_Objects/Math", "fr": "fr/R\u00e9f\u00e9rence_de_JavaScript_1.5_Core/Objets_globaux/Math", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/Math" } ) }}```