// operators/RoundingNumbers.java// (c)2017 MindView LLC: see Copyright.txt// We make no guarantees that this code is fit for any purpose.// Visit http://OnJava8.com for more book information.// Rounding floats and doublespublic class RoundingNumbers {public static void main(String[] args) {double above = 0.7, below = 0.4;float fabove = 0.7f, fbelow = 0.4f;System.out.println("Math.round(above): " + Math.round(above));System.out.println("Math.round(below): " + Math.round(below));System.out.println("Math.round(fabove): " + Math.round(fabove));System.out.println("Math.round(fbelow): " + Math.round(fbelow));}}/* Output:Math.round(above): 1Math.round(below): 0Math.round(fabove): 1Math.round(fbelow): 0*/
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。