मुझे आश्चर्य है कि यह क्यों संकलित करता है? और इसका मतलब क्या है क्योंकि यह संकलित करता है?0xp0 प्रिंट 0.0 (हेक्साडेसिमल फ्लोटिंग प्वाइंट लिटल)
System.out.println(0xp0); // p?
उत्पादन:
0.0
मुझे आश्चर्य है कि यह क्यों संकलित करता है? और इसका मतलब क्या है क्योंकि यह संकलित करता है?0xp0 प्रिंट 0.0 (हेक्साडेसिमल फ्लोटिंग प्वाइंट लिटल)
System.out.println(0xp0); // p?
उत्पादन:
0.0
यह एक फ़्लोटिंग पॉइंट हेक्स शाब्दिक है।
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.
विनिर्देश here देखें।
+1 खैर, पहली बार मुझे फ्लोटिंग पॉइंट हेक्स के बारे में पता है। –
The JLS यह बताते हैं:
HexadecimalFloatingPointLiteral:
HexSignificand BinaryExponent FloatTypeSuffixopt
HexSignificand:
HexNumeral
HexNumeral .
0 x HexDigitsopt . HexDigits
0 X HexDigitsopt . HexDigits
BinaryExponent:
BinaryExponentIndicator SignedInteger
BinaryExponentIndicator:one of
p P
ऊपर के आधार पर, मैं एक अनिवार्य .HexDigit
p
से पहले हालांकि उम्मीद करेंगे।
मेरे लिए यह संकलन नहीं है, 'javac 1.7.0_02' साथ। केवल '0x0p0' करता है। –
@TheGuyOfDoom मैं '1.7.0_05' का उपयोग कर रहा हूं। –
मैं सूर्य जेडीके के रास्ते से हूं। यह प्रासंगिक हो सकता है। –