java – JLS似乎与自相矛盾
作者:互联网
请查看Oracle Specification – Chapter 5.
这一行:
A widening primitive conversion does not lose information about the
overall magnitude of a numeric value.
接下来,只有2行,这条线表示幅度信息可能会丢失.
A widening primitive conversion from float to double that is not
strictfp may lose information about the overall magnitude of the
converted value.
这似乎是一个明显的矛盾;这是一个错误吗?
解决方法:
对于它的价值,JVM规范在2.11.4的措辞中更加清晰:
Widening numeric conversions do not lose information about the overall magnitude of a numeric value. Indeed, conversions widening from int to long and int to double do not lose any information at all; the numeric value is preserved exactly. Conversions widening from float to double that are FP-strict (§2.8.2) also preserve the numeric value exactly; however, such conversions that are not FP-strict may lose information about the overall magnitude of the converted value.
标签:jls,java 来源: https://codeday.me/bug/20190825/1719249.html