package com.heilong.math;
/*
* Math 数学类,主要提供很多数学公式
*
* abs(double a) 获取绝对值
* ceil(double a) 向上取整
* floor(double a) 向下取整
* round(float a) 四舍五入
* random() 返回带正号的double值,该值大于等于0.0且小于1.0
*
* */
public class Demo1 {
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());
}
}
Java Math类
最新推荐文章于 2023-05-01 15:43:38 发布