1         System.out.println(Math.round(-12.7));//输出-13
 2         System.out.println(Math.round(-12.5));//输出-12
 3         System.out.println(Math.round(-12.4));//输出-12
 4         System.out.println(Math.round(12.5));//输出13
 5         System.out.println(Math.round(12.4));//输出12
 6         
 7         System.out.println("------------");
 8         
 9         System.out.println(Math.ceil(1.5));//输出2.0
10         System.out.println(Math.ceil(1.4));//输出2.0
11         System.out.println(Math.ceil(-1.5));//输出-1.0
12         System.out.println(Math.ceil(-1.6));//输出-1.0
13         System.out.println(Math.ceil(-1.4));//输出-1.0
14         
15         System.out.println("------------");
16         
17         System.out.println(Math.floor(1.5));//输出1.0
18         System.out.println(Math.floor(1.4));//输出1.0
19         System.out.println(Math.floor(-1.6));//输出-2.0
20         System.out.println(Math.floor(-1.5));//输出-2.0
21         System.out.println(Math.floor(-1.4));//输出-2.0

 

相关文章:

  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
  • 2021-12-01
  • 2022-02-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-10-19
相关资源
相似解决方案