From Jason Turner

[lex.icon]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp79q3fpjr/{from.md → to.md} +37 -32
tmp/tmp79q3fpjr/{from.md → to.md} RENAMED
@@ -31,13 +31,12 @@ decimal-literal:
31
  hexadecimal-literal:
32
  hexadecimal-prefix hexadecimal-digit-sequence
33
  ```
34
 
35
  ``` bnf
36
- binary-digit:
37
- '0'
38
- '1'
39
  ```
40
 
41
  ``` bnf
42
  octal-digit: one of
43
  '0 1 2 3 4 5 6 7'
@@ -87,38 +86,44 @@ long-suffix: one of
87
  ``` bnf
88
  long-long-suffix: one of
89
  'll LL'
90
  ```
91
 
92
- An *integer literal* is a sequence of digits that has no period or
93
- exponent part, with optional separating single quotes that are ignored
94
- when determining its value. An integer literal may have a prefix that
95
- specifies its base and a suffix that specifies its type. The lexically
96
- first digit of the sequence of digits is the most significant. A *binary
97
- integer literal* (base two) begins with `0b` or `0B` and consists of a
98
- sequence of binary digits. An *octal integer literal* (base eight)
99
- begins with the digit `0` and consists of a sequence of octal
100
- digits.[^12] A *decimal integer literal* (base ten) begins with a digit
101
- other than `0` and consists of a sequence of decimal digits. A
102
- *hexadecimal integer literal* (base sixteen) begins with `0x` or `0X`
103
- and consists of a sequence of hexadecimal digits, which include the
104
- decimal digits and the letters `a` through `f` and `A` through `F` with
 
 
 
 
 
 
105
  decimal values ten through fifteen.
106
 
107
  [*Example 1*: The number twelve can be written `12`, `014`, `0XC`, or
108
- `0b1100`. The integer literals `1048576`, `1'048'576`, `0X100000`,
109
  `0x10'0000`, and `0'004'000'000` all have the same
110
  value. — *end example*]
111
 
112
- The type of an integer literal is the first of the corresponding list in
113
- Table  [[tab:lex.type.integer.literal]] in which its value can be
114
- represented.
115
 
116
- **Table: Types of integer literals** <a id="tab:lex.type.integer.literal">[tab:lex.type.integer.literal]</a>
117
 
118
- | | | |
119
- | ---------------- | ------------------------ | ------------------------ |
120
  | none | `int` | `int` |
121
  | | `long int` | `unsigned int` |
122
  | | `long long int` | `long int` |
123
  | | | `unsigned long int` |
124
  | | | `long long int` |
@@ -136,16 +141,16 @@ represented.
136
  | | | `unsigned long long int` |
137
  | Both `u` or `U` | `unsigned long long int` | `unsigned long long int` |
138
  | and `ll` or `LL` | | |
139
 
140
 
141
- If an integer literal cannot be represented by any type in its list and
142
- an extended integer type ([[basic.fundamental]]) can represent its
143
  value, it may have that extended integer type. If all of the types in
144
- the list for the integer literal are signed, the extended integer type
145
- shall be signed. If all of the types in the list for the integer literal
146
- are unsigned, the extended integer type shall be unsigned. If the list
147
- contains both signed and unsigned types, the extended integer type may
148
- be signed or unsigned. A program is ill-formed if one of its translation
149
- units contains an integer literal that cannot be represented by any of
150
- the allowed types.
151
 
 
31
  hexadecimal-literal:
32
  hexadecimal-prefix hexadecimal-digit-sequence
33
  ```
34
 
35
  ``` bnf
36
+ binary-digit: one of
37
+ '0 1'
 
38
  ```
39
 
40
  ``` bnf
41
  octal-digit: one of
42
  '0 1 2 3 4 5 6 7'
 
86
  ``` bnf
87
  long-long-suffix: one of
88
  'll LL'
89
  ```
90
 
91
+ In an *integer-literal*, the sequence of *binary-digit*s,
92
+ *octal-digit*s, *digit*s, or *hexadecimal-digit*s is interpreted as a
93
+ base N integer as shown in table [[lex.icon.base]]; the lexically first
94
+ digit of the sequence of digits is the most significant.
95
+
96
+ [*Note 1*: The prefix and any optional separating single quotes are
97
+ ignored when determining the value. *end note*]
98
+
99
+ **Table: Base of *integer-literal*{s}** <a id="lex.icon.base">[lex.icon.base]</a>
100
+
101
+ | Kind of *integer-literal* | base $N$ |
102
+ | ------------------------- | -------- |
103
+ | *binary-literal* | 2 |
104
+ | *octal-literal* | 8 |
105
+ | *decimal-literal* | 10 |
106
+ | *hexadecimal-literal* | 16 |
107
+
108
+
109
+ The *hexadecimal-digit*s `a` through `f` and `A` through `F` have
110
  decimal values ten through fifteen.
111
 
112
  [*Example 1*: The number twelve can be written `12`, `014`, `0XC`, or
113
+ `0b1100`. The *integer-literal*s `1048576`, `1'048'576`, `0X100000`,
114
  `0x10'0000`, and `0'004'000'000` all have the same
115
  value. — *end example*]
116
 
117
+ The type of an *integer-literal* is the first type in the list in
118
+ [[lex.icon.type]] corresponding to its optional *integer-suffix* in
119
+ which its value can be represented. An *integer-literal* is a prvalue.
120
 
121
+ **Table: Types of *integer-literal*s** <a id="lex.icon.type">[lex.icon.type]</a>
122
 
123
+ | *integer-suffix* | *decimal-literal* | *integer-literal* other than *decimal-literal* |
124
+ | ---------------- | ------------------------ | ---------------------------------------------- |
125
  | none | `int` | `int` |
126
  | | `long int` | `unsigned int` |
127
  | | `long long int` | `long int` |
128
  | | | `unsigned long int` |
129
  | | | `long long int` |
 
141
  | | | `unsigned long long int` |
142
  | Both `u` or `U` | `unsigned long long int` | `unsigned long long int` |
143
  | and `ll` or `LL` | | |
144
 
145
 
146
+ If an *integer-literal* cannot be represented by any type in its list
147
+ and an extended integer type [[basic.fundamental]] can represent its
148
  value, it may have that extended integer type. If all of the types in
149
+ the list for the *integer-literal* are signed, the extended integer type
150
+ shall be signed. If all of the types in the list for the
151
+ *integer-literal* are unsigned, the extended integer type shall be
152
+ unsigned. If the list contains both signed and unsigned types, the
153
+ extended integer type may be signed or unsigned. A program is ill-formed
154
+ if one of its translation units contains an *integer-literal* that
155
+ cannot be represented by any of the allowed types.
156