问题描述
我一直在尝试转换字符串中的大十进制值,我从数据库转换为十进制。
通过解析双方法将值转换为指数...
我可以做些什么来获得确切的值。
数据库中的值:36319512.42
字符串到十进制转换给出:3.631951242E7
预期小数值:36319512.42(独立于no。是多久)
使用的方法:
String ab = rs.getString(1);
double1 = Double.parseDouble(ab);
DecimalFormat df = new DecimalFormat( 0.00);
df.setMaximumFractionDigits(2);
df.format(double1);
System.out.println(ab:+ ab);
System.out.println(double1:+ double1);
i have been trying to convert large decimal values in string, which i get from database into decimal.
the values are converted to exponents by parse double method...
can i do something to get the exact value.
value in database : 36319512.42
string to decimal conversion gives: 3.631951242E7
expected decimal value : 36319512.42 (independent of how long the no. is)
method used:
String ab= rs.getString(1);
double1 = Double.parseDouble(ab);
DecimalFormat df = new DecimalFormat("0.00");
df.setMaximumFractionDigits(2);
df.format(double1);
System.out.println("ab: "+ ab );
System.out.println("double1: "+ double1);
推荐答案
System.out.println("double1: "+ df.format(double1));
这篇关于使用java将包含大十进制数的字符串转换为十进制数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!