java基础面试题:Math.round(11.5)等於多少? Math.round(-11.5)等於多少?
package com.swift; public class Math_Round { public static void main(String[] args) { /* * Math round为+0.5后的floor(也可以说正数四舍五入负数五舍六入) ceil天花板 floor地板 */ System.out.println(Math.round(11.4)); System.out.println(Math.round(11.5)); System.out.println(Math.round(11.6)); System.out.println(Math.round(-11.4));//-11.4+0.5=-10.9 取floor为-11 System.out.println(Math.round(-11.5));//-11.5+0.5=-11 取floor为-11 System.out.println(Math.round(-11.6));//-11.6+0.5=-11.1 取floor 为-12 } }
Never waste time any more, Never old man be a yong man