[英]Double.parseDouble error java retrieve SOA
I GET SOA STRING USE Double.parseDouble fd.setFdrRate(Double.parseDouble(coreFD.getInterestRate()));我得到 SOA 字符串使用 Double.parseDouble fd.setFdrRate(Double.parseDouble(coreFD.getInterestRate())); message SOA return 3.7 but screen show 3.7000000000000005 save Database return 3.7 help me to check
消息 SOA 返回 3.7 但屏幕显示 3.7000000000000005 保存数据库返回 3.7 帮我检查
double
cannot represent the number 3.7
with full precision. double
不能以全精度表示数字3.7
。 You may consider using BigDecimal instead:您可以考虑改用BigDecimal :
new BigDecimal(coreFD.getInterestRate()).toString() // 3.7
PS Always use BigDecimal
(or similar-purpose class) for storing finance-related numbers. PS始终使用
BigDecimal
(或类似用途的类)来存储与财务相关的数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.