-
Notifications
You must be signed in to change notification settings - Fork 7
/
spec.html
67 lines (67 loc) · 3.33 KB
/
spec.html
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
<!DOCTYPE html>
<meta charset="utf-8">
<pre class="metadata">
title: '`{BigInt,Number}.fromString`'
status: proposal
stage: 1
location: https://mathiasbynens.github.io/proposal-number-fromstring/
copyright: false
contributors: Mathias Bynens
</pre>
<script src="ecmarkup.js" defer></script>
<link rel="stylesheet" href="ecmarkup.css">
<style>
hr {
height: 0.25em;
background: #ccc;
border: 0;
margin: 2em 0;
}
</style>
<emu-clause id="sec-bigint-fromstring-string-radix">
<h1>BigInt.fromString ( _string_, _radix_ )</h1>
<p>The `BigInt.fromString` function produces an integer value dictated by interpretation of the contents of the _string_ argument according to the specified _radix_. If _radix_ is *undefined*, it is assumed to be 10.</p>
<p>When the `BigInt.fromString` function is called, the following steps are taken:</p>
<emu-alg>
1. If Type(_string_) is not String, throw a *TypeError* exception.
1. If _string_ is empty, throw a *SyntaxError* exception.
1. Let _sign_ be 1.
1. If the first code unit of _string_ is the code unit 0x002D (HYPHEN-MINUS), then
1. Let _sign_ be -1.
1. Remove the first code unit from _string_.
1. If _string_ is empty, throw a *SyntaxError* exception.
1. If _radix_ is not present, let _R_ be 10.
1. Else if _radix_ is *undefined*, let _R_ be 10.
1. Else, let _R_ be ? ToInteger(_radix_).
1. If _R_ < 2 or _R_ > 36, throw a *RangeError* exception.
1. If _string_ represents a mathematical integer value in radix-_R_ notation, using the characters <b>0</b>-<b>9</b> for digits with values 0 to 9, and the letters <b>a</b>-<b>z</b> for digits with values 10 through 35, then
1. Let _mathInt_ be that mathematical integer value.
1. Else, throw a *SyntaxError* exception.
1. Let _number_ be _sign_ × _mathInt_.
1. Return the BigInt value for _number_.
</emu-alg>
</emu-clause>
<hr>
<emu-clause id="sec-number-fromstring-string-radix">
<h1>Number.fromString ( _string_, _radix_ )</h1>
<p>The `Number.fromString` function produces a numeric value dictated by interpretation of the contents of the _string_ argument according to the specified _radix_. If _radix_ is *undefined*, it is assumed to be 10.</p>
<p>When the `Number.fromString` function is called, the following steps are taken:</p>
<emu-alg>
1. If Type(_string_) is not String, throw a *TypeError* exception.
1. If _string_ is empty, throw a *SyntaxError* exception.
1. Let _sign_ be 1.
1. If the first code unit of _string_ is the code unit 0x002D (HYPHEN-MINUS), then
1. Let _sign_ be -1.
1. Remove the first code unit from _string_.
1. If _string_ is empty, throw a *SyntaxError* exception.
1. If _radix_ is not present, let _R_ be 10.
1. Else if _radix_ is *undefined*, let _R_ be 10.
1. Else, let _R_ be ? ToInteger(_radix_).
1. If _R_ < 2 or _R_ > 36, throw a *RangeError* exception.
1. If _string_ represents a mathematical number value in radix-_R_ notation, using the characters <b>0</b>-<b>9</b> for digits with values 0 to 9, and the letters <b>a</b>-<b>z</b> for digits with values 10 through 35, then
1. Let _mathNum_ be that mathematical number value.
1. Else, throw a *SyntaxError* exception.
1. Let _number_ be _sign_ × _mathNum_.
1. Return the Number value for _number_.
</emu-alg>
</emu-clause>