2 Lexical conventions [lex]2.13 Literals [lex.literal]2.13.1 Integer literals [lex.icon]
| 2 词法约定 【词法】2.13 文字量 【词法.文字量】2.13.1 整数文字量 【词法.整数常量】
|
integer-literal: decimal-literal integer-suffixopt octal-literal integer-suffixopt hexadecimal-literal integer-suffixopt decimal-literal: octal-literal: hexadecimal-literal: nonzero-digit: one of octal-digit: one of hexadecimal-digit: one of integer-suffix: unsigned-suffix: one if long-suffix: one of
| 整数-文字量: 十进制-文字量 整数-后缀opt 八进制-文字量 整数-后缀opt 十六进制-文字量 整数-后缀opt 十进制-文字量: 八进制-文字量: 十六进制-文字量: 非零-数字: 下列之一 八进制-数字: 下列之一 十六进制-数字: 下列之一 整数-后缀: unsigned-后缀: 下列之一 long-后缀: 下列之一
|
An integer literal is a sequence of digits that has no period or exponent part. An integer literal may have a prefix that specifies its base and a suffix that specifies its type. The lexically first digit of the sequence of digits is the most significant. A decimal integer literal (base ten) begins with a digit other than 0 and consists of a sequence of decimal digits. An octal integer literal (base eight) begins with the digit 0 and consists of a sequence of octal digits.22) A hexadecimal integer literal (base sixteen) begins with 0x or 0X and consists of a sequence of hexadecimal digits, which include the decimal digits and the letters a through f and A through F with decimal values ten through fifteen. [Example: the number twelve can be written 12 , 014 , or 0XC . ]
| 整数文字量是不含有句点或指数部分的数字序列。整数文字量可能包含指定其基数的前缀或指定其类型的后缀。数字序列词法的第一个数字最重要。十进制整数文字量开始于不是 0 的数字并由十进制数字序列构成。八进制整数文字量开始于数字 0 并由八进制数字序列构成。22) 十六进制整数文字量开始于 0x 或 0X 并由十六进制数字序列构成,十六进制数字包括十进制数字和用以表示十进制数值从十到十五的,从 a 到 f 以及从 A 到 F 的字母。【例:数值十二可以被写成 12 ,014 ,或 0XC 。】
|
The type of an integer literal depends on its form, value, and suffix. If it is decimal and has no suffix, it has the first of these types in which its value can be represented: int , long int ; if the value cannot be represented as a long int , the behavior is undefined. If it is octal or hexadecimal and has no suffix, it has the first of these types in which its value can be represented: int , unsigned int , long int , unsigned long int . If it is suffixed by u or U , its type is the first of these types in which its value can be represented: unsigned int , unsigned long int . If it is suffixed by l or L , its type is the first of these types in which its value can be represented: long int , unsigned long int . If it is suffixed by ul , lu , uL , Lu , Ul , lU , UL , or LU , its type is unsigned long int .
| 整数文字量的类型以来于其形式,值,以及后缀。如果它是十进制的并且没有后缀,则其具有下列能够表达其值的第一个类型:int ,long int ;如果其值不能被 long int 表达,其行为是未定义的。如果它是八进制或十六进制并且没有后缀,则其具有下列能够表达其值的第一个类型:int ,unsigned int ,long int ,unsigned long int 。如果它具有后缀 u 或 U ,则其具有下列能够表达其值的第一个类型:unsigned int ,unsigned long int 。如果它具有后缀 l 或 L ,则其具有下列能够表达其值的第一个类型:long int ,unsigned long int 。如果它具有后缀 ul ,lu ,uL ,Lu ,Ul ,lU ,UL ,或 LU , 则其具有类型 unsigned long int 。
|
A program is ill-formed if one of its translation units contains an integer literal that cannot be represented by any of the allowed types.
| 若一个程序的任一翻译单元包含任何不能被允许的类型表达的整数文字量,则它是病态形式的。
|
22) The digits 8 and 9 are not octal digits.
| 22) 数字 8 和 9 不是八进制数字。
|
PREV [lex.literal] | NEXT [lex.ccon] | 上一页 【词法.文字量】 | 下一页 【词法.字符常量】 |
2.13.1 - [lex.icon] - 【词法.整数常量】
最新推荐文章于 2020-12-03 22:58:17 发布
请不要转载本文;请不要以任何形式重新出版,发布本文;请在下载本文 24 小时内将其删除;禁止将本文用于商业目的。