在我的代码中,我使用整数乘以 100 作为小数(0.1 是 10 等).你能帮我格式化输出以显示为十进制吗?
in my code i use integers multiplied by 100 as decimals (0.1 is 10 etc). Can you help me to format output to show it as decimal?
int x = 100;
DecimalFormat df = new DecimalFormat("#.00"); // Set your desired format here.
System.out.println(df.format(x/100.0));
这篇关于在Java中打印带有2位小数的整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!