You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/expressions/literal-expr.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,18 @@ let a: u64 = 123; // type u64
59
59
0usize; // type usize
60
60
```
61
61
62
+
The value of the expression is determined from the string representation of the token as follows:
63
+
64
+
* An integer radix is chosen by inspecting the first two characters of the string: `0b` indicates radix 2, `0o` indicates radix 8, `0x` indicates radix 16; otherwise the radix is 10.
65
+
66
+
* If the radix is not 10, the first two characters are removed from the string.
67
+
68
+
* Any underscores are removed from the string.
69
+
70
+
* The string is converted to a `u128` value as if by [`u128::from_str_radix`] with the chosen radix.
71
+
72
+
* The `u128` value is converted to the expression's type via a [numeric cast].
73
+
62
74
## Floating-point literal expressions
63
75
64
76
A floating-point literal expression consists of a single [FLOAT_LITERAL] token.
0 commit comments