在Java中float和double的包含范围是多少? [英] What is the inclusive range of float and double in Java?

查看:698
本文介绍了在Java中float和double的包含范围是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



为什么不建议在精度至关重要的地方使用float或double?

解决方案

Java的 Double 类包含该类型的最小值和最大值的成员。

  2 ^ -1074< = x< =(2-2 ^ -52)·2 ^ 1023 // where x是双倍的。 

查看 Min_VALUE MAX_VALUE 静态最终成员 Double



(some)建议不要使用浮点类型进行准确性和精确度至关重要的事情,因为舍入误差可以通过可衡量的(小)数量来抛弃计算。


What is the inclusive range of float and double in Java?

Why are you not recommended to use float or double for anything where precision is critical?

解决方案

Java's Double class has members containing the Min and Max value for the type.

2^-1074 <= x <= (2-2^-52)·2^1023 // where x is the double.

Check out the Min_VALUE and MAX_VALUE static final members of Double.

(some)People will suggest against using floating point types for things where accuracy and precision are critical because rounding errors can throw off calculations by measurable (small) amounts.

这篇关于在Java中float和double的包含范围是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆