有个问题。
假设 num1=1 num2 =0.001
当 num1+num2+num2+num2+num2+num2也就是说 num1加 num2 多次后 会发生 一个小小的错误
不是完全正确的结果 这个问题如何解决
高手请。 。
假设 num1=1 num2 =0.001
当 num1+num2+num2+num2+num2+num2也就是说 num1加 num2 多次后 会发生 一个小小的错误
不是完全正确的结果 这个问题如何解决
高手请。 。
解决方案 »
- 看effective java 发现一个小问题
- 程序老是报错:No getter method for property: "password2" of bean
- Ext查询
- 小问题,求各位大神们解答
- at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1905)错误如何解决
- spring父子容器
- Struts写RequestProcessor编码问题
- 在unix下面用poi导出excel的问题。
- myeclipse中html出现乱码。。。。
- 江湖救急啊啊啊ognl.OgnlException: target is null for setProperty(null, "taskStatus"
- 这是什么异常
- 用Document解析xml的时候,用parse()怎么获得当前的uri?
public int intValue()
Returns the value of this Float as an int (by casting to type int). Specified by:
intValue in class Number
Returns:
the float value represented by this object converted to type int
int temp = 0;
temp = num2.intValue();sum = num1 + temp;
那你要用
java.math
Class BigDecimal
java.lang.Object
|
+-java.lang.Number
|
+-java.math.BigDecimal里的方法了。add
public BigDecimal add(BigDecimal val)
Returns a BigDecimal whose value is (this val), and whose scale is max(this.scale(), val.scale()). Parameters:
val - value to be added to this BigDecimal.
Returns:
this val