【发布时间】:2016-01-02 17:04:18
【问题描述】:
Vector <Double> v=new Vector<Double>();
for (double d=1;d<=50;d++) {
v.add(d);
v.add((double)Math.round((d*1.3)*100/100));
}
System.out.println(Math.round((5.255685650*1.3)*100/100));
System.out.println("Multiples of 1.3 is -->"+v);
我想要像 45.54 这样的小数,它也存储在向量中。 请告诉我..
【问题讨论】:
-
那么究竟是什么问题?
-
你想做什么?
-
你为什么使用
Vector?现在是 2016 年,而不是 1996 年。 -
您的问题设置小数点后两位,已经回答here!
-
你的右括号放错了位置。试试
Math.round((d*1.3)*100)/100而不是Math.round((d*1.3)*100/100)
标签: java vector collections double rounding