Skip to content

Commit 307cf03

Browse files
authored
[spec/lex] Tweak integer literal docs (#3643)
Use list for formatting. Mention C octal example. Add examples.
1 parent e5d9fdc commit 307cf03

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

spec/lex.dd

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,19 +762,28 @@ $(GNAME HexLetter):
762762

763763
$(P Integers can be specified in decimal, binary, or hexadecimal.)
764764

765-
$(P Decimal integers are a sequence of decimal digits.)
765+
$(UL
766+
$(LI Decimal integers are a sequence of decimal digits.)
766767

767-
$(P $(LNAME2 binary-literals, Binary integers) are a sequence of binary digits preceded
768+
$(LI $(LNAME2 binary-literals, Binary integers) are a sequence of binary digits preceded
768769
by a $(SINGLEQUOTE 0b) or $(SINGLEQUOTE 0B).
769770
)
770771

771-
$(P C-style octal integer notation was deemed too easy to mix up with decimal notation;
772+
$(LI C-style octal integer notation (e.g. `0167`) was deemed too easy to mix up with decimal notation;
772773
it is only fully supported in string literals.
773774
D still supports octal integer literals interpreted at compile time through the $(REF octal, std,conv)
774775
template, as in $(D octal!167).)
775-
$(P Hexadecimal integers are a sequence of hexadecimal digits preceded
776+
777+
$(LI Hexadecimal integers are a sequence of hexadecimal digits preceded
776778
by a $(SINGLEQUOTE 0x) or $(SINGLEQUOTE 0X).
777779
)
780+
)
781+
782+
---
783+
10 // decimal
784+
0b1010 // binary
785+
0xA // hex
786+
---
778787

779788
$(P Integers can have embedded $(SINGLEQUOTE $(UNDERSCORE)) characters after a digit to improve readability, which are ignored.
780789
)
@@ -783,6 +792,7 @@ $(GNAME HexLetter):
783792
20_000 // leagues under the sea
784793
867_5309 // number on the wall
785794
1_522_000 // thrust of F1 engine (lbf sea level)
795+
0xBAAD_F00D // magic number for debugging
786796
---
787797

788798
$(P Integers can be immediately followed by one $(SINGLEQUOTE L) or one of

0 commit comments

Comments
 (0)