免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1659 | 回复: 0
打印 上一主题 下一主题

关于2种浮点数类型的适用范围的差异---FLOAT和DOUBLE [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-10-12 16:58 |只看该作者 |倒序浏览
以下关于2种浮点数类型适描述,来自《Core Java2,Volume1:Fundamentals 6Edition》
==============================
Floating-Point Types
The floating-point types denote numbers with fractional parts.

The name double refers to the fact that these numbers have twice the precision of the float type. (Some people call these double-precision numbers.) Here, the type to choose in most applications is double. The limited precision of float is simply not sufficient for many situations. Seven significant (decimal) digits may be enough to precisely express your annual salary in dollars and cents, but it won't be enough for your company president's salary.
The only reason to use float is in the rare situations in which the slightly faster processing of single-precision numbers is important, or when you need to store a large number of them.
==============================

以下是我对红色部分的翻译,可能不准确,但主要意思应该没错吧:7位有效数字(10进制)可以足够精确地表示你那以美圆美分来计算的年薪;但对于你公司的董事长,这就力不从心了。


我对这句话不理解:7位数的精度,应该是指小数点后的位数吧?为什么不能表示一个富豪,比如BILL GATES的年薪?难道他的年薪能超过FLOAT的表示范围?

float, 4 bytes, approximately ±3.40282347E+38F (6–7 significant decimal digits),是不是在JAVA里只能用这种表示方式?

请各位指点。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP