Reputation: 367
Following these two lines:
float f1 = 2E10f;
float f2 = 0x2P10f;
The output is:
2.0E10
2048.0
Respectively.
So my question is:
What is E10 and P10 equivalent to in decimals?
I think E10 equivalent to 1010, is that true?
Upvotes: 1
Views: 439
Reputation: 2323
E and P are exponent indicators in floating point literals. You can also express number in decimal (base 10) or hexadecimal (base 16).
2E10f
is 2*10^10
(decimal base with exponent indicator)0x2P10f
is 2*2^10
(hexadecimal base with binary exponent indicator)Upvotes: 2
Reputation: 95958
I think E10 equivalent to 10^10(10 to the power of 10), is that true?
Yes. Proof:
System.out.println(new BigDecimal(2.0E10).toPlainString());
Output will be 20000000000.
Meaning that E10 is 1010. ∎
Upvotes: 0