not getting the proper output in number format

半腔热情 提交于 2019-12-25 19:58:14

问题


I am formating numbers in locale US. The problem i am facing is that it's not displaying the exact number user gives rather it's displaying upto 8 digit number.

In the childview it shows the user input but when i try to display it i n the groupview it's displaying only 8 digits

Code:
NumberFormat numberFormat= NumberFormat.getNumberInstance(locale);
numberFormat.format(double);// double is the user given input

回答1:


The problem is that double cannot hold so many significant digits (mantissa). You should use BigDecimal here otherwise you can always lose precision.



来源:https://stackoverflow.com/questions/29986358/not-getting-the-proper-output-in-number-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!