float是32bit
double是64bit
是二进制表示的,不是BCD码,因此不能以十进制的概念说double能表示到小数点后面几位,也不能精确进行运算,试一试,0.05+0.01等于几?要控制位数,可以用
new java.text.DecimalFormat("0.00000")。fo;

解决方案 »

  1.   

    new java.text.DecimalFormat("0.00000").format(yourValue);
      

  2.   

    这和java无关,c什么的都是这样
    与整形不同并非从最小值到最大值之间的每个值都可以精确表示出来
    仔细想一下32bit, 64bit只能表示2^32和2^64(18446744073709551616)种不同的值,
    而double的最大值1.7976931348623157e+308也就是1后面308个0, 可见其精度是相当低的
      

  3.   

    The differece between 1.3d and 1.3f is the precision(精确度) not the range 1.3 is default to double precision(精确度) number,assigning it to a float will lose precision(精确度),It will need a case!