aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/javascript/reference/global_objects/number/positive_infinity/index.html
blob: e54b1b7e2d551772dc24134732e12b9ea67a3033 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
title: Number.POSITIVE_INFINITY
slug: Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY
translation_of: Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY
---
<div>{{JSRef}}</div>

<p>A propriedade <strong><code>Number.POSITIVE_INFINITY</code></strong> representa o valor positivo infinito.</p>

<p>Você não precisa criar um objeto {{jsxref("Number")}} para utilizar a propriedade estática (use <code>Number.POSITIVE_INFINITY</code>).</p>

<div>{{js_property_attributes(0, 0, 0)}}</div>

<h2 id="Descrição">Descrição</h2>

<p>O valor de <code>Number.POSITIVE_INFINITY</code> é o mesmo valor da propriedade {{jsxref("Infinity")}} do objeto global.</p>

<p>Esse valor se comporta ligeiramente diferente do infinito matemático:</p>

<ul>
 <li>Qualquer valor positivo, incluindo <code>POSITIVE_INFINITY</code>, multiplicado por <code>POSITIVE_INFINITY</code> é <code>POSITIVE_INFINITY</code>.</li>
 <li>Qualquer valor negativo, incluindo, {{jsxref("Number.NEGATIVE_INFINITY", "NEGATIVE_INFINITY")}}, multiplicado por <code>POSITIVE_INFINITY</code> é {{jsxref("Number.NEGATIVE_INFINITY", "NEGATIVE_INFINITY")}}.</li>
 <li>Qualquer número positivo dividido por <code>POSITIVE_INFINITY</code> é Zero positivo.</li>
 <li>Qualquer número negativo dividido por <code>POSITIVE_INFINITY</code> é Zero negativo.</li>
 <li>Zero multiplicado por <code>POSITIVE_INFINITY</code> é {{jsxref("NaN")}}.</li>
 <li>{{jsxref("Global_Objects/NaN", "NaN")}} multiplicado por <code>POSITIVE_INFINITY</code> é {{jsxref("NaN")}}.</li>
 <li><code>POSITIVE_INFINITY</code>, dividido por qualquer valor negativo exceto {{jsxref("Number.NEGATIVE_INFINITY", "NEGATIVE_INFINITY")}}, é {{jsxref("Number.NEGATIVE_INFINITY", "NEGATIVE_INFINITY")}}.</li>
 <li><code>POSITIVE_INFINITY</code>, dividido por qualquer valor positivo exceto <code>POSITIVE_INFINITY</code>, é <code>POSITIVE_INFINITY</code>.</li>
 <li><code>POSITIVE_INFINITY</code>, dividido por {{jsxref("Number.NEGATIVE_INFINITY", "NEGATIVE_INFINITY")}} ou <code>POSITIVE_INFINITY</code>, é {{jsxref("NaN")}}.</li>
</ul>

<p>Você pode usar a propriedade <code>Number.POSITIVE_INFINITY</code> para indicar uma condição de erro que retorna um número finito no caso de sucesso. Sobretudo, {{jsxref("isFinite")}} seria mais apropriado nesse caso.</p>

<h2 id="Exemplos">Exemplos</h2>

<h3 id="Usando_POSITIVE_INFINITY">Usando <code>POSITIVE_INFINITY</code></h3>

<p>No exemplo a seguir, a variável <code>bigNumber</code> recebe um valor maior que o valor máximo. Quando as declarações {{jsxref("Statements/if...else", "if")}} executam, <code>bigNumber</code> tem o valor <code>Infinity</code>, então <code>bigNumber</code> recebe um valor mais gerenciável antes de continuar.</p>

<pre class="brush: js">var bigNumber = Number.MAX_VALUE * 2;

if (bigNumber == Number.POSITIVE_INFINITY) {
  bigNumber = returnFinite();
}
</pre>

<h2 id="Especificação">Especificação</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Especificação</th>
   <th scope="col">Status</th>
   <th scope="col">Comentário</th>
  </tr>
  <tr>
   <td>{{SpecName('ES1')}}</td>
   <td>{{Spec2('ES1')}}</td>
   <td>Initial definition. Implemented in JavaScript 1.1.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.7.3.6', 'Number.POSITIVE_INFINITY')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-number.positive_infinity', 'Number.POSITIVE_INFINITY')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-number.positive_infinity', 'Number.POSITIVE_INFINITY')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Compatibilidade com navegadores</h2>

<p>{{Compat("javascript.builtins.Number.POSITIVE_INFINITY")}}</p>

<h2 id="Ver_também">Ver também</h2>

<ul>
 <li>{{jsxref("Number.NEGATIVE_INFINITY")}}</li>
 <li>{{jsxref("Number.isFinite()")}}</li>
 <li>{{jsxref("Infinity")}}</li>
 <li>{{jsxref("isFinite", "isFinite()")}}</li>
</ul>