当我们必须使用a _分隔数字中的数字时,我无法理解以下无法使用的情况: - In positions where a string of digits is expected
_
你不具备使用”_”,你可以。提案中提供的示例包括信用卡号,电话号码或仅在代码中使用分隔符的数字。
对于“在期望数字串的位置”,它只是在应该以数字开头(或结束)的地方。这里有些例子。
请注意,根据此建议,下划线只能放在数字之间。不能将它们自己放置在通常期望数字串的位置:
int x1 = _52; // This is an identifier, not a numeric literal.
int x2 = 5_2; // OK. (Decimal literal)
int x2 = 52_; // Illegal. (Underscores must always be between digits)
int x3 = 5_2; // OK. (Decimal literal.)
int x4 = 0_x52; // Illegal. Can’t put underscores in the “0x” radix prefix.
int x5 = 0x_52; // Illegal. (Underscores must always be between digits)
int x6 = 0x5_2; // OK. (Hexadecimal literal)
int x6 = 0x52_; // Illegal. (Underscores must always be between digits)
int x6 = 0x_; // Illegal. (Not valid with the underscore removed)
int x7 = 0_52; // OK. (Octal literal)
int x7 = 05_2; // OK. (Octal literal)
int x8 = 052_; // Illegal. (Underscores must always be between digits)