public class TestMath { public static void main(String[] args) { System.out.println(Math.E); System.out.println(Math.PI); System.out.println(Math.abs(-3.5)); System.out.println(Math.ceil(3.5)); // >= System.out.println(Math.floor(3.5)); // <= System.out.println(Math.pow(2, 3)); System.out.println(Math.random());// 0-1之间随机数 System.out.println(Math.round(3.5)); // 四舍五入 } }
2.718281828459045 3.141592653589793 3.5 4.0 3.0 8.0 0.2921187058255972 4
时间: 2024-11-05 12:21:05