没有得到数字格式正确的输出 [英] not getting the proper output in number format

查看:152
本文介绍了没有得到数字格式正确的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在格式化的数字语言环境美。我面临的问题是,它不显示确切的数字用户给出,而其显示高达8位数字。

在childview它显示了用户的输入,但是当我尝试以显示它I N的groupview它只能显示8位
 
code:

 的NumberFormat NUMBERFORMAT = NumberFormat.getNumberInstance(区域);
numberFormat.format(双); //双是用户给定的输入


解决方案

的问题是,双击无法容纳这么多的显著位(尾数)。您应该使用的BigDecimal 在这里,否则你总是可以输precision。

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

解决方案

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

这篇关于没有得到数字格式正确的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆