|
799 | 799 | \indextext{literal!integer}%
|
800 | 800 | \begin{bnf}
|
801 | 801 | \nontermdef{integer-literal}\br
|
802 |
| - decimal-literal integer-suffix\opt\br |
| 802 | + binary-literal integer-suffix\opt\br |
803 | 803 | octal-literal integer-suffix\opt\br
|
804 |
| - hexadecimal-literal integer-suffix\opt\br |
805 |
| - binary-literal integer-suffix\opt |
| 804 | + decimal-literal integer-suffix\opt\br |
| 805 | + hexadecimal-literal integer-suffix\opt |
806 | 806 | \end{bnf}
|
807 | 807 |
|
808 | 808 | \begin{bnf}
|
809 |
| -\nontermdef{decimal-literal}\br |
810 |
| - nonzero-digit\br |
811 |
| - decimal-literal \terminal{'}\opt digit |
| 809 | +\nontermdef{binary-literal}\br |
| 810 | + \terminal{0b} binary-digit\br |
| 811 | + \terminal{0B} binary-digit\br |
| 812 | + binary-literal \terminal{'}\opt binary-digit |
812 | 813 | \end{bnf}
|
813 | 814 |
|
814 | 815 | \begin{bnf}
|
|
817 | 818 | octal-literal \terminal{'}\opt octal-digit
|
818 | 819 | \end{bnf}
|
819 | 820 |
|
| 821 | +\begin{bnf} |
| 822 | +\nontermdef{decimal-literal}\br |
| 823 | + nonzero-digit\br |
| 824 | + decimal-literal \terminal{'}\opt digit |
| 825 | +\end{bnf} |
| 826 | + |
820 | 827 | \begin{bnf}
|
821 | 828 | \nontermdef{hexadecimal-literal}\br
|
822 | 829 | \terminal{0x} hexadecimal-digit\br
|
|
825 | 832 | \end{bnf}
|
826 | 833 |
|
827 | 834 | \begin{bnf}
|
828 |
| -\nontermdef{binary-literal}\br |
829 |
| - \terminal{0b} binary-digit\br |
830 |
| - \terminal{0B} binary-digit\br |
831 |
| - binary-literal \terminal{'}\opt binary-digit |
| 835 | +\nontermdef{binary-digit}\br |
| 836 | + \terminal{0}\br |
| 837 | + \terminal{1} |
832 | 838 | \end{bnf}
|
833 | 839 |
|
834 | 840 | \begin{bnf}
|
835 |
| -\nontermdef{nonzero-digit} \textnormal{one of}\br |
836 |
| - \terminal{1 2 3 4 5 6 7 8 9} |
| 841 | +\nontermdef{octal-digit} \textnormal{one of}\br |
| 842 | + \terminal{0 1 2 3 4 5 6 7} |
837 | 843 | \end{bnf}
|
838 | 844 |
|
839 | 845 | \begin{bnf}
|
840 |
| -\nontermdef{octal-digit} \textnormal{one of}\br |
841 |
| - \terminal{0 1 2 3 4 5 6 7} |
| 846 | +\nontermdef{nonzero-digit} \textnormal{one of}\br |
| 847 | + \terminal{1 2 3 4 5 6 7 8 9} |
842 | 848 | \end{bnf}
|
843 | 849 |
|
844 | 850 | \begin{bnf}
|
|
848 | 854 | \terminal{A B C D E F}
|
849 | 855 | \end{bnf}
|
850 | 856 |
|
851 |
| -\begin{bnf} |
852 |
| -\nontermdef{binary-digit}\br |
853 |
| - \terminal{0}\br |
854 |
| - \terminal{1} |
855 |
| -\end{bnf} |
856 |
| - |
857 | 857 | \begin{bnf}
|
858 | 858 | \nontermdef{integer-suffix}\br
|
859 | 859 | unsigned-suffix long-suffix\opt \br
|
|
881 | 881 | \indextext{literal!\idxcode{unsigned}}%
|
882 | 882 | \indextext{literal!\idxcode{long}}%
|
883 | 883 | \indextext{literal!integer}%
|
884 |
| -\indextext{literal!hexadecimal}% |
| 884 | +\indextext{literal!binary}% |
885 | 885 | \indextext{literal!octal}%
|
886 | 886 | \indextext{literal!decimal}%
|
887 |
| -\indextext{literal!binary}% |
| 887 | +\indextext{literal!hexadecimal}% |
888 | 888 | \indextext{literal!base~of integer}%
|
889 | 889 | An \term{integer literal} is a sequence of digits that has no period
|
890 | 890 | or exponent part, with optional separating single quotes that are ignored
|
891 | 891 | when determining its value. An integer literal may have a prefix that specifies
|
892 | 892 | its base and a suffix that specifies its type. The lexically first digit
|
893 |
| -of the sequence of digits is the most significant. A \term{decimal} |
894 |
| -integer literal (base ten) begins with a digit other than \tcode{0} and |
895 |
| -consists of a sequence of decimal digits. An \term{octal} integer |
| 893 | +of the sequence of digits is the most significant. |
| 894 | +A \term{binary} integer literal (base two) begins with |
| 895 | +\tcode{0b} or \tcode{0B} and consists of a sequence of binary digits. |
| 896 | +An \term{octal} integer |
896 | 897 | literal (base eight) begins with the digit \tcode{0} and consists of a
|
897 | 898 | sequence of octal digits.\footnote{The digits \tcode{8} and \tcode{9} are not octal digits. }
|
| 899 | +A \term{decimal} |
| 900 | +integer literal (base ten) begins with a digit other than \tcode{0} and |
| 901 | +consists of a sequence of decimal digits. |
898 | 902 | A \term{hexadecimal} integer literal (base sixteen) begins with
|
899 | 903 | \tcode{0x} or \tcode{0X} and consists of a sequence of hexadecimal
|
900 | 904 | digits, which include the decimal digits and the letters \tcode{a}
|
901 | 905 | through \tcode{f} and \tcode{A} through \tcode{F} with decimal values
|
902 |
| -ten through fifteen. A \term{binary} integer literal (base two) begins with |
903 |
| -\tcode{0b} or \tcode{0B} and consists of a sequence of binary digits. |
| 906 | +ten through fifteen. |
904 | 907 | \enterexample The number twelve can be written \tcode{12}, \tcode{014},
|
905 | 908 | \tcode{0XC}, or \tcode{0b1100}. The literals \tcode{1048576},
|
906 | 909 | \tcode{1'048'576}, \tcode{0X100000}, \tcode{0x10'0000}, and
|
|
0 commit comments