向上取整:比自己大的最小整数。
向下取整:比自己小的最大整数。

public class RoundingUp {
    public static void main(String[] args) {
        System.out.println(Math.ceil(1.5)); //2.0
        System.out.println(Math.ceil(-1.5)); //-1.0
        System.out.println(Math.floor(1.5)); //1.0
        System.out.println(Math.floor(-1.5)); //-2.0
    }
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-03-07
猜你喜欢
  • 2021-11-23
  • 2021-12-27
  • 2021-08-17
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案