Java中Float的最大值?
以下问题表示 Double 的最小值为-Double.MAX_VALUE
。对于 Float(即 -Float.MAX_VALUE
)来说也是如此吗?
The following question indicates that the minimum value of a Double is -Double.MAX_VALUE
. Is this also true for Float (i.e., -Float.MAX_VALUE
)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的,
-Float.MAX_VALUE
是最大量值的负数。float
的表示方式与double
相同,只是存储空间减半(以及随之而来的精度损失)。由于 IEEE 754 中的符号由单个表示位,翻转该位不会改变其余位可达到的总体幅度。Yes,
-Float.MAX_VALUE
is the negative number with largest magnitude.float
s are represented the same way asdouble
s, just with half the storage space (and the accompanying loss of precision.) Since signs in IEEE 754 are represented by a single bit, flipping that bit doesn't change the overall magnitude attainable by the remaining bits.是的 - 它与 Float.MAX_VALUE 的位模式相同,只是符号位翻转了......这是获取该值的另一种方法:
Yes - it's the same bit pattern as
Float.MAX_VALUE
except with the sign bit flipped... and that's another way to get at the value:编辑:我原来的答案似乎非常不正确。感谢@aioobe 指出了这一点。
相反,使用java代码的魔力来回答标题问题:
Float.MAX_VALUE: 340,282,346,638,528,860,000,000,000,000,000,000,000.000000
in science notation: 3.40282346638528860e+38
in hexadecimal带有尾数和指数的浮点数:0x1.fffffep127
EDIT: My original answer appears to be badly incorrect. Thank you @aioobe for pointing this out.
Instead, using the magic of java code to answer the title question:
Float.MAX_VALUE: 340,282,346,638,528,860,000,000,000,000,000,000,000.000000
in scientific notation: 3.40282346638528860e+38
in hexadecimal floating-point number with a significand and an exponent: 0x1.fffffep127
是的,Float 也是如此。
有关详细信息,请查看此处的手册 http://download。 oracle.com/javase/7/docs/api/java/lang/Float.html
Yes, it's also true for Float.
For more information check the manual here http://download.oracle.com/javase/7/docs/api/java/lang/Float.html
是的,由于与您链接的问题的答案中所述的原因完全相同,浮点数和双精度数使用 IEEE754 表示,由于它们的存储方式,该表示是“对称的”。
Yes it is, and for exactly the same reason as stated in the answer for the question you linked, Floats and Doubles use IEEE754 representation which is "symmetrical" due to the way they are stored.