/*
 Math 数学类, 主要是提供了很多的数学公式。
 
 abs(double a)  获取绝对值
 ceil(double a)  向上取整
 floor(double a)  向下取整
 round(float a)   四舍五入
 random()   产生一个随机数. 大于等于 0.0 且小于 1.0 的伪随机 double 值
 
 */


public class Demo4 {
    
    public static void main(String[] args) {
        System.out.println("绝对值:"+Math.abs(-3));
        System.out.println("向上取整:"+Math.ceil(3.14));
        System.out.println("向下取整:"+Math.floor(-3.14)); //
        System.out.println("四舍五入:"+Math.round(3.54));
        System.out.println("随机数:"+Math.random());
        
    }
    
}

 

相关文章:

  • 2022-01-08
  • 2021-11-14
  • 2021-05-27
  • 2021-09-29
猜你喜欢
  • 2022-01-07
  • 2021-08-31
  • 2021-11-03
  • 2022-12-23
  • 2021-09-14
  • 2021-07-28
  • 2022-02-12
相关资源
相似解决方案