Skip to content

Commit 40772d0

Browse files
Update integers-and-floating-point-numbers.md (#42755)
* Update integers-and-floating-point-numbers.md This sentence also confuses me. Copied from [StefanKarpinski](https://discourse.julialang.org/t/i-can-not-understand-the-meaning-of-this-sentence-on-the-doc/21010) * Update integers-and-floating-point-numbers.md * fix whitespace Co-authored-by: Viral B. Shah <[email protected]>
1 parent 79b0226 commit 40772d0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

doc/src/manual/integers-and-floating-point-numbers.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,18 @@ UInt128
173173
As for hexadecimal literals, binary and octal literals produce unsigned integer types. The size
174174
of the binary data item is the minimal needed size, if the leading digit of the literal is not
175175
`0`. In the case of leading zeros, the size is determined by the minimal needed size for a
176-
literal, which has the same length but leading digit `1`. That allows the user to control
177-
the size.
176+
literal, which has the same length but leading digit `1`. It means that:
177+
178+
- `0x1` and `0x12` are `UInt8` literals,
179+
- `0x123` and `0x1234` are `UInt16` literals,
180+
- `0x12345` and `0x12345678` are `UInt32` literals,
181+
- `0x123456789` and `0x1234567890adcdef` are `UInt64` literals, etc.
182+
183+
Even if there are leading zero digits which don’t contribute to the value, they count for
184+
determining storage size of a literal. So `0x01` is a `UInt8` while `0x0001` is a `UInt16`.
185+
186+
That allows the user to control the size.
187+
178188
Values which cannot be stored in `UInt128` cannot be written as such literals.
179189

180190
Binary, octal, and hexadecimal literals may be signed by a `-` immediately preceding the

0 commit comments

Comments
 (0)