From Jason Turner

[lex.fcon]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp6s1ghyza/{from.md → to.md} +51 -46
tmp/tmp6s1ghyza/{from.md → to.md} RENAMED
@@ -1,23 +1,23 @@
1
- ### Floating literals <a id="lex.fcon">[[lex.fcon]]</a>
2
 
3
  ``` bnf
4
- floating-literal:
5
- decimal-floating-literal
6
- hexadecimal-floating-literal
7
  ```
8
 
9
  ``` bnf
10
- decimal-floating-literal:
11
- fractional-constant exponent-partₒₚₜ floating-suffixₒₚₜ
12
- digit-sequence exponent-part floating-suffixₒₚₜ
13
  ```
14
 
15
  ``` bnf
16
- hexadecimal-floating-literal:
17
- hexadecimal-prefix hexadecimal-fractional-constant binary-exponent-part floating-suffixₒₚₜ
18
- hexadecimal-prefix hexadecimal-digit-sequence binary-exponent-part floating-suffixₒₚₜ
19
  ```
20
 
21
  ``` bnf
22
  fractional-constant:
23
  digit-sequenceₒₚₜ '.' digit-sequence
@@ -52,46 +52,51 @@ digit-sequence:
52
  digit
53
  digit-sequence '''ₒₚₜ digit
54
  ```
55
 
56
  ``` bnf
57
- floating-suffix: one of
58
  'f l F L'
59
  ```
60
 
61
- A floating literal consists of an optional prefix specifying a base, an
62
- integer part, a radix point, a fraction part, an `e`, `E`, `p` or `P`,
63
- an optionally signed integer exponent, and an optional type suffix. The
64
- integer and fraction parts both consist of a sequence of decimal (base
65
- ten) digits if there is no prefix, or hexadecimal (base sixteen) digits
66
- if the prefix is `0x` or `0X`. The floating literal is a *decimal
67
- floating literal* in the former case and a *hexadecimal floating
68
- literal* in the latter case. Optional separating single quotes in a
69
- *digit-sequence* or *hexadecimal-digit-sequence* are ignored when
70
- determining its value.
71
-
72
- [*Example 1*: The floating literals `1.602'176'565e-19` and
73
- `1.602176565e-19` have the same value. — *end example*]
74
-
75
- Either the integer part or the fraction part (not both) can be omitted.
76
- Either the radix point or the letter `e` or `E` and the exponent (not
77
- both) can be omitted from a decimal floating literal. The radix point
78
- (but not the exponent) can be omitted from a hexadecimal floating
79
- literal. The integer part, the optional radix point, and the optional
80
- fraction part, form the *significand* of the floating literal. In a
81
- decimal floating literal, the exponent, if present, indicates the power
82
- of 10 by which the significand is to be scaled. In a hexadecimal
83
- floating literal, the exponent indicates the power of 2 by which the
84
- significand is to be scaled.
85
-
86
- [*Example 2*: The floating literals `49.625` and `0xC.68p+2` have the
87
- same value. *end example*]
88
-
89
- If the scaled value is in the range of representable values for its
90
- type, the result is the scaled value if representable, else the larger
91
- or smaller representable value nearest the scaled value, chosen in an
92
- *implementation-defined* manner. The type of a floating literal is
93
- `double` unless explicitly specified by a suffix. The suffixes `f` and
94
- `F` specify `float`, the suffixes `l` and `L` specify `long` `double`.
 
 
95
  If the scaled value is not in the range of representable values for its
96
- type, the program is ill-formed.
 
 
 
97
 
 
1
+ ### Floating-point literals <a id="lex.fcon">[[lex.fcon]]</a>
2
 
3
  ``` bnf
4
+ floating-point-literal:
5
+ decimal-floating-point-literal
6
+ hexadecimal-floating-point-literal
7
  ```
8
 
9
  ``` bnf
10
+ decimal-floating-point-literal:
11
+ fractional-constant exponent-partₒₚₜ floating-point-suffixₒₚₜ
12
+ digit-sequence exponent-part floating-point-suffixₒₚₜ
13
  ```
14
 
15
  ``` bnf
16
+ hexadecimal-floating-point-literal:
17
+ hexadecimal-prefix hexadecimal-fractional-constant binary-exponent-part floating-point-suffixₒₚₜ
18
+ hexadecimal-prefix hexadecimal-digit-sequence binary-exponent-part floating-point-suffixₒₚₜ
19
  ```
20
 
21
  ``` bnf
22
  fractional-constant:
23
  digit-sequenceₒₚₜ '.' digit-sequence
 
52
  digit
53
  digit-sequence '''ₒₚₜ digit
54
  ```
55
 
56
  ``` bnf
57
+ floating-point-suffix: one of
58
  'f l F L'
59
  ```
60
 
61
+ The type of a *floating-point-literal* is determined by its
62
+ *floating-point-suffix* as specified in [[lex.fcon.type]].
63
+
64
+ **Table: Types of *floating-point-literal*{s}** <a id="lex.fcon.type">[lex.fcon.type]</a>
65
+
66
+ | *floating-point-suffix* | type |
67
+ | ----------------------- | --------------- |
68
+ | none | `double` |
69
+ | `f` or `F` | `float` |
70
+ | `l` or `L` | `long` `double` |
71
+
72
+
73
+ The *significand* of a *floating-point-literal* is the
74
+ *fractional-constant* or *digit-sequence* of a
75
+ *decimal-floating-point-literal* or the
76
+ *hexadecimal-fractional-constant* or *hexadecimal-digit-sequence* of a
77
+ *hexadecimal-floating-point-literal*. In the significand, the sequence
78
+ of *digit*s or *hexadecimal-digit*s and optional period are interpreted
79
+ as a base N real number s, where N is 10 for a
80
+ *decimal-floating-point-literal* and 16 for a
81
+ *hexadecimal-floating-point-literal*.
82
+
83
+ [*Note 1*: Any optional separating single quotes are ignored when
84
+ determining the value. *end note*]
85
+
86
+ If an *exponent-part* or *binary-exponent-part* is present, the exponent
87
+ e of the *floating-point-literal* is the result of interpreting the
88
+ sequence of an optional *sign* and the *digit*s as a base 10 integer.
89
+ Otherwise, the exponent e is 0. The scaled value of the literal is
90
+ s × 10ᵉ for a *decimal-floating-point-literal* and s × 2ᵉ for a
91
+ *hexadecimal-floating-point-literal*.
92
+
93
+ [*Example 1*: The *floating-point-literal*s `49.625` and `0xC.68p+2`
94
+ have the same value. The *floating-point-literal*s `1.602'176'565e-19`
95
+ and `1.602176565e-19` have the same value. — *end example*]
96
+
97
  If the scaled value is not in the range of representable values for its
98
+ type, the program is ill-formed. Otherwise, the value of a
99
+ *floating-point-literal* is the scaled value if representable, else the
100
+ larger or smaller representable value nearest the scaled value, chosen
101
+ in an *implementation-defined* manner.
102