在Java中打印2位小数的整数
发布时间:2020-12-14 05:03:58 所属栏目:Java 来源:网络整理
导读:在我的代码中,我使用整数乘以100作为小数(0.1为10等).你可以帮我格式化输出以显示为十进制吗? 解决方法 int x = 100;DecimalFormat df = new DecimalFormat("#.00"); // Set your desired format here.System.out.println(df.format(x/100.0));
在我的代码中,我使用整数乘以100作为小数(0.1为10等).你可以帮我格式化输出以显示为十进制吗?
解决方法int x = 100; DecimalFormat df = new DecimalFormat("#.00"); // Set your desired format here. System.out.println(df.format(x/100.0)); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |