Skip to content

Commit 44f7210

Browse files
Document how the value of a floating-point literal expression is determined
For now, refer to the stdlib docs for the actual interpretation.
1 parent 012e207 commit 44f7210

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/expressions/literal-expr.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,21 @@ Examples of floating-point literal expressions:
102102
let x: f64 = 2.; // type f64
103103
```
104104

105+
The value of the expression is determined from the string representation of the token as follows:
106+
107+
* Any underscores are removed from the string.
108+
109+
* The string is converted to the expression's type as if by [`f32::from_str`] or [`f64::from_str`].
110+
105111
[constant expression]: ../const_eval.md#constant-expressions
106112
[floating-point types]: ../types/numeric.md#floating-point-types
107113
[lint check]: ../attributes/diagnostics.md#lint-check-attributes
108114
[literal tokens]: ../tokens.md#literals
109115
[numeric cast]: operator-expr.md#numeric-cast
110116
[numeric types]: ../types/numeric.md
111117
[suffix]: ../tokens.md#suffixes
118+
[`f32::from_str`]: ../../core/primitive.f32.md#method.from_str
119+
[`f64::from_str`]: ../../core/primitive.f64.md#method.from_str
112120
[`u128::from_str_radix`]: ../../core/primitive.u128.md#method.from_str_radix
113121
[CHAR_LITERAL]: ../tokens.md#character-literals
114122
[STRING_LITERAL]: ../tokens.md#string-literals

0 commit comments

Comments
 (0)