我有一个数组,一个双数组,例如...
Double my_array = new Double[] {6272640.0, 43560.0, 4840.0, 0.0015625, 4046856422.400000095, 40468564.223999999, 4046.856422400, 0.004046856, 1.0, 0.404685642};
在我的程序中,我想将每个元素与一些整数值相乘... 我通过变量 n 接受它。
我在我的程序中完成了它...
for(int 1=0;i<my_array.length;i++)
{
my_array[i] = n*my_array[i];
}
当我尝试打印结果时,我得到的值是指数...... 比如,3.23E等等……
我需要结果为最多 8 位小数的 double 值...
我应该怎么做才能得到它
最佳答案
您应该格式化输出。
http://docs.oracle.com/javase/tutorial/java/data/numberformat.html(一般解释) http://download.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html(格式化符号)
double yourDouble = 0.1234567890;
DecimalFormat myFormatter = new DecimalFormat("0.00000000");
System.out.println(myFormatter.format(yourDouble));
应打印“0.12345678”。
关于java - 不带精度和逗号的双数乘法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8178696/