| OLD | NEW |
| 1 --- | 1 --- |
| 2 layout: article | 2 layout: article |
| 3 title: "Numeric Computation" | 3 title: "Numeric Computation" |
| 4 rel: | 4 rel: |
| 5 author: john-mccutchan | 5 author: john-mccutchan |
| 6 description: "How you store and use numbers can have a big impact on your app's
performance. This article focuses on the Dart VM, with additional tips for apps
that are compiled to JavaScript." | 6 description: "How you store and use numbers can have a big impact on your app's
performance. This article focuses on the Dart VM, with additional tips for apps
that are compiled to JavaScript." |
| 7 has-permalinks: true | 7 has-permalinks: true |
| 8 article: | 8 article: |
| 9 written_on: 2013-05-22 | 9 written_on: 2013-05-22 |
| 10 collection: performance | 10 collection: performance |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 as numbers grow and shrink in range. | 64 as numbers grow and shrink in range. |
| 65 | 65 |
| 66 <table class="table table-bordered"> | 66 <table class="table table-bordered"> |
| 67 <tr> | 67 <tr> |
| 68 <th> Internal representation </th> | 68 <th> Internal representation </th> |
| 69 <td> smi (<b>sm</b>all <b>i</b>nteger) </td> | 69 <td> smi (<b>sm</b>all <b>i</b>nteger) </td> |
| 70 <td> mint (<b>m</b>edium <b>int</b>eger) </td> | 70 <td> mint (<b>m</b>edium <b>int</b>eger) </td> |
| 71 <td> bigint </td> | 71 <td> bigint </td> |
| 72 </tr> | 72 </tr> |
| 73 <tr> | 73 <tr> |
| 74 <th> Minimum value </th> | 74 <th> Minimum value </th> |
| 75 <td> -2<sup>30</sup> (on a 32-bit machine) | 75 <td> -2<sup>30</sup> (on a 32-bit machine) |
| 76 <br> | 76 <br> |
| 77 -2<sup>62</sup> (on a 64-bit machine)</td> | 77 -2<sup>62</sup> (on a 64-bit machine)</td> |
| 78 <td> -2<sup>63</sup> </td> | 78 <td> -2<sup>63</sup> </td> |
| 79 <td> Limited by RAM </td> | 79 <td> Limited by RAM </td> |
| 80 </tr> | 80 </tr> |
| 81 <tr> | 81 <tr> |
| 82 <th> Maximum value </th> | 82 <th> Maximum value </th> |
| 83 <td> 2<sup>30</sup> - 1 (on a 32-bit machine) | 83 <td> 2<sup>30</sup> - 1 (on a 32-bit machine) |
| 84 <br> | 84 <br> |
| 85 2<sup>62</sup> - 1 (on a 64-bit machine)</td> | 85 2<sup>62</sup> - 1 (on a 64-bit machine)</td> |
| 86 <td> 2<sup>63</sup> - 1 </td> | 86 <td> 2<sup>63</sup> - 1 </td> |
| 87 <td> Limited by RAM </td> | 87 <td> Limited by RAM </td> |
| 88 </tr> | 88 </tr> |
| 89 </table> | 89 </table> |
| 90 | 90 |
| 91 Here is an example of how a single integer value in the VM | 91 Here is an example of how a single integer value in the VM |
| 92 graduates from smi to mint to bigint: | 92 graduates from smi to mint to bigint: |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 | 576 |
| 577 ### Typed lists | 577 ### Typed lists |
| 578 | 578 |
| 579 JavaScript offers typed arrays | 579 JavaScript offers typed arrays |
| 580 that are compatible with Dart’s typed lists. | 580 that are compatible with Dart’s typed lists. |
| 581 The mapping is trivial—for example, | 581 The mapping is trivial—for example, |
| 582 Float32List becomes a Float32Array. | 582 Float32List becomes a Float32Array. |
| 583 The one exception today is that dart2js does not support 64-bit integers | 583 The one exception today is that dart2js does not support 64-bit integers |
| 584 and thus does not support Int64List or Uint64List. | 584 and thus does not support Int64List or Uint64List. |
| 585 Dart code compiled via dart2js results in a runtime exception | 585 Dart code compiled via dart2js results in a runtime exception |
| 586 if either of those lists is used. | 586 if either of those lists is used. |
| OLD | NEW |