|
497 | 497 | pp-number \terminal{'} nondigit\br
|
498 | 498 | pp-number \terminal{e} sign\br
|
499 | 499 | pp-number \terminal{E} sign\br
|
| 500 | + pp-number \terminal{p} sign\br |
| 501 | + pp-number \terminal{P} sign\br |
500 | 502 | pp-number \terminal{.}
|
501 | 503 | \end{bnf}
|
502 | 504 |
|
|
803 | 805 |
|
804 | 806 | \begin{bnf}
|
805 | 807 | \nontermdef{hexadecimal-literal}\br
|
806 |
| - \terminal{0x} hexadecimal-digit\br |
807 |
| - \terminal{0X} hexadecimal-digit\br |
808 |
| - hexadecimal-literal \terminal{'}\opt hexadecimal-digit |
| 808 | + hexadecimal-prefix hexadecimal-digit-sequence |
809 | 809 | \end{bnf}
|
810 | 810 |
|
811 | 811 | \begin{bnf}
|
|
824 | 824 | \terminal{1 2 3 4 5 6 7 8 9}
|
825 | 825 | \end{bnf}
|
826 | 826 |
|
| 827 | +\begin{bnf} |
| 828 | +\nontermdef{hexadecimal-prefix} \textnormal{one of}\br |
| 829 | + \terminal{0x 0X} |
| 830 | +\end{bnf} |
| 831 | + |
| 832 | +\begin{bnf} |
| 833 | +\nontermdef{hexadecimal-digit-sequence}\br |
| 834 | + hexadecimal-digit\br |
| 835 | + hexadecimal-digit-sequence \terminal{'}\opt hexadecimal-digit |
| 836 | +\end{bnf} |
| 837 | + |
827 | 838 | \begin{bnf}
|
828 | 839 | \nontermdef{hexadecimal-digit} \textnormal{one of}\br
|
829 | 840 | \terminal{0 1 2 3 4 5 6 7 8 9}\br
|
|
1202 | 1213 | \indextext{literal!floating}%
|
1203 | 1214 | \begin{bnf}
|
1204 | 1215 | \nontermdef{floating-literal}\br
|
| 1216 | + decimal-floating-literal\br |
| 1217 | + hexadecimal-floating-literal |
| 1218 | +\end{bnf} |
| 1219 | + |
| 1220 | +\begin{bnf} |
| 1221 | +\nontermdef{decimal-floating-literal}\br |
1205 | 1222 | fractional-constant exponent-part\opt floating-suffix\opt\br
|
1206 | 1223 | digit-sequence exponent-part floating-suffix\opt
|
1207 | 1224 | \end{bnf}
|
1208 | 1225 |
|
| 1226 | +\begin{bnf} |
| 1227 | +\nontermdef{hexadecimal-floating-literal}\br |
| 1228 | + hexadecimal-prefix hexadecimal-fractional-constant binary-exponent-part floating-suffix\opt\br |
| 1229 | + hexadecimal-prefix hexadecimal-digit-sequence binary-exponent-part floating-suffix\opt |
| 1230 | +\end{bnf} |
| 1231 | + |
1209 | 1232 | \begin{bnf}
|
1210 | 1233 | \nontermdef{fractional-constant}\br
|
1211 | 1234 | digit-sequence\opt{} \terminal{.} digit-sequence\br
|
1212 | 1235 | digit-sequence \terminal{.}
|
1213 | 1236 | \end{bnf}
|
1214 | 1237 |
|
| 1238 | +\begin{bnf} |
| 1239 | +\nontermdef{hexadecimal-fractional-constant}\br |
| 1240 | + hexadecimal-digit-sequence\opt{} \terminal{.} hexadecimal-digit-sequence\br |
| 1241 | + hexadecimal-digit-sequence \terminal{.} |
| 1242 | +\end{bnf} |
| 1243 | + |
1215 | 1244 | \begin{bnf}
|
1216 | 1245 | \nontermdef{exponent-part}\br
|
1217 | 1246 | \terminal{e} sign\opt digit-sequence\br
|
1218 | 1247 | \terminal{E} sign\opt digit-sequence
|
1219 | 1248 | \end{bnf}
|
1220 | 1249 |
|
| 1250 | +\begin{bnf} |
| 1251 | +\nontermdef{binary-exponent-part}\br |
| 1252 | + \terminal{p} sign\opt digit-sequence\br |
| 1253 | + \terminal{P} sign\opt digit-sequence |
| 1254 | +\end{bnf} |
| 1255 | + |
1221 | 1256 | \begin{bnf}
|
1222 | 1257 | \nontermdef{sign} \textnormal{one of}\br
|
1223 | 1258 | \terminal{+ -}
|
|
1236 | 1271 |
|
1237 | 1272 | \pnum
|
1238 | 1273 | \indextext{literal!floating}%
|
1239 |
| -A floating literal consists of an integer part, a decimal point, a |
1240 |
| -fraction part, an |
| 1274 | +A floating literal consists of |
| 1275 | +an optional prefix specifying a base, |
| 1276 | +an integer part, |
| 1277 | +a radix point, |
| 1278 | +a fraction part, |
1241 | 1279 | \indextext{suffix!\idxcode{e}}%
|
1242 | 1280 | \indextext{suffix!\idxcode{E}}%
|
1243 |
| -\tcode{e} or \tcode{E}, an optionally signed integer exponent, and an |
1244 |
| -optional type suffix. The integer and fraction parts both consist of a |
1245 |
| -sequence of decimal (base ten) digits. Optional separating single quotes in a |
1246 |
| -\grammarterm{digit-sequence} are ignored when determining its value. |
| 1281 | +\indextext{suffix!\idxcode{p}}% |
| 1282 | +\indextext{suffix!\idxcode{P}}% |
| 1283 | +an \tcode{e}, \tcode{E}, \tcode{p} or \tcode{P}, |
| 1284 | +an optionally signed integer exponent, and |
| 1285 | +an optional type suffix. |
| 1286 | +The integer and fraction parts both consist of |
| 1287 | +a sequence of decimal (base ten) digits if there is no prefix, or |
| 1288 | +hexadecimal (base sixteen) digits if the prefix is \tcode{0x} or \tcode{0X}. |
| 1289 | +\indextext{literal!decimal floating}% |
| 1290 | +The literal is a \term{decimal floating literal} in the former case and |
| 1291 | +\indextext{literal!hexadecimal floating}% |
| 1292 | +a \term{hexadecimal floating literal} in the latter case. |
| 1293 | +Optional separating single quotes in |
| 1294 | +a \grammarterm{digit-sequence} or \grammarterm{hexadecimal-digit-sequence} |
| 1295 | +are ignored when determining its value. |
1247 | 1296 | \enterexample The literals \tcode{1.602'176'565e-19} and \tcode{1.602176565e-19}
|
1248 | 1297 | have the same value. \exitexample
|
1249 |
| -Either the integer part or the |
1250 |
| -fraction part (not both) can be omitted; either the decimal point or the |
1251 |
| -letter \tcode{e} (or \tcode{E} ) and the exponent (not both) can be |
1252 |
| -omitted. The integer part, the optional decimal point and the optional |
1253 |
| -fraction part form the \term{significant part} of the |
1254 |
| -floating literal. The exponent, if present, indicates the power of 10 by |
1255 |
| -which the significant part is to be scaled. If the scaled value is in |
| 1298 | +Either the integer part or the fraction part (not both) can be omitted. |
| 1299 | +Either the radix point or the letter \tcode{e} or \tcode{E} and |
| 1300 | +the exponent (not both) can be omitted from a decimal floating literal. |
| 1301 | +The radix point (but not the exponent) can be omitted |
| 1302 | +from a hexadecimal floating literal. |
| 1303 | +The integer part, the optional radix point, and the optional fraction part, |
| 1304 | +form the \defn{significand} of the floating literal. |
| 1305 | +In a decimal floating literal, the exponent, if present, |
| 1306 | +indicates the power of 10 by which the significand is to be scaled. |
| 1307 | +In a hexadecimal floating literal, the exponent |
| 1308 | +indicates the power of 2 by which the significand is to be scaled. |
| 1309 | +\enterexample |
| 1310 | +The literals \tcode{49.625} and \tcode{0xC.68p+2} have the same value. |
| 1311 | +\exitexample |
| 1312 | +If the scaled value is in |
1256 | 1313 | the range of representable values for its type, the result is the scaled
|
1257 | 1314 | value if representable, else the larger or smaller representable value
|
1258 | 1315 | nearest the scaled value, chosen in an \impldef{choice of larger or smaller value of
|
|
1615 | 1672 | \begin{bnf}
|
1616 | 1673 | \nontermdef{user-defined-floating-literal}\br
|
1617 | 1674 | fractional-constant exponent-part\opt ud-suffix\br
|
1618 |
| - digit-sequence exponent-part ud-suffix |
| 1675 | + digit-sequence exponent-part ud-suffix\br |
| 1676 | + hexadecimal-prefix hexadecimal-fractional-constant binary-exponent-part ud-suffix\br |
| 1677 | + hexadecimal-prefix hexadecimal-digit-sequence binary-exponent-part ud-suffix |
1619 | 1678 | \end{bnf}
|
1620 | 1679 |
|
1621 | 1680 | \begin{bnf}
|
|
0 commit comments