[英]0xp0 prints 0.0 (Hexadecimal Floating Point Literal)
I just wonder why this compiles? 我只是想知道为什么这个编译? and what does it mean since it does compile?
它是什么意思,因为它编译?
System.out.println(0xp0); // p?
OUTPUT: OUTPUT:
0.0
HexadecimalFloatingPointLiteral:
HexSignificand BinaryExponent FloatTypeSuffixopt
HexSignificand:
HexNumeral
HexNumeral .
0 x HexDigitsopt . HexDigits
0 X HexDigitsopt . HexDigits
BinaryExponent:
BinaryExponentIndicator SignedInteger
BinaryExponentIndicator:one of
p P
Based on the above, I would expect a mandatory .HexDigit
before the p
, though. 基于以上所述,我希望在
p
之前有一个强制的.HexDigit
。
It's a floating point hex literal. 这是一个浮点十六进制文字。
For hexadecimal floating-point literals, at least one digit is required (in either the whole number or the fraction part), and the exponent is mandatory, and the float type suffix is optional.
对于十六进制浮点文字,至少需要一个数字(在整数或小数部分中),并且指数是必需的,浮点类型后缀是可选的。 The exponent is indicated by the ASCII letter p or P followed by an optionally signed integer.
指数由ASCII字母p或P表示,后跟可选的有符号整数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.