package roundTest;
public class RoundTest {
public static void main(String[] args) {
//规则:+0.5,向下取整
System.out.println(Math.round(-1.5));//-1.5+0.5=-1,向下取整-1
System.out.println(Math.round(-1.50001));//-1.50001+0.5=-1.0001,向下取整-2
System.out.println(Math.round(1.5));//1.5+0.5=2,向下取整2
}
}
Java_Math.round()方法取整规则:+0.5向下取整
最新推荐文章于 2024-05-24 07:30:00 发布