[英]Floating point literal syntax
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? E10和P10等于十进制的多少?
I think E10 equivalent to 10 10 , is that true? 我认为E10等于10 10 ,是真的吗?
E and P are exponent indicators in floating point literals . E和P是浮点文字中的指数指示符。 You can also express number in decimal (base 10) or hexadecimal (base 16).
您也可以用十进制(以10为底)或十六进制(以16为底)表示数字。
2E10f
is 2*10^10
(decimal base with exponent indicator) 2E10f
为2*10^10
(带指数指示符的十进制基数) 0x2P10f
is 2*2^10
(hexadecimal base with binary exponent indicator) 0x2P10f
为2*2^10
(带二进制指数指示符的十六进制基数) I think E10 equivalent to 10^10(10 to the power of 10), is that true?
我认为E10等于10 ^ 10(10等于10的幂),是真的吗?
Yes. 是。 Proof:
证明:
Use BigDecimal#toPlainString
: 使用
BigDecimal#toPlainString
:
System.out.println(new BigDecimal(2.0E10).toPlainString());
Output will be 20000000000. 输出将为20000000000。
Meaning that E10 is 10 10 . 意思是E10是10 10 。 ∎
∎
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.