- 论坛徽章:
- 0
|
以下关于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里只能用这种表示方式?
请各位指点。 |
|