问问题
4949 次
2 回答
2
because val/100 is an Integer operation, so the deciaml part is stripped away. For instane
int i = 1;
int result = i / 2;
will give you 0
Change to System.out.println(nf.format(((float)val/100)));
于 2013-07-02T10:04:46.673 回答
2
To force floating point arithmetic , you can use a double literal 100.0
or float literal 100.0f
:
System.out.println(nf.format(val/100.0));
于 2013-07-02T10:10:09.160 回答