标签:code eth 结果 print out round stat sqrt java
1 package math; 2 3 public class MathMethod { 4 public static void main(String[] args) { System.out.println(Math.abs(10));//10 5 System.out.println( Math.abs(-10));//10 6 //pow 7 System.out.println((int) Math.pow(2,4));//16 8 System.out.println(Math.pow(2,-4)); 9 10 System.out.println(Math.ceil(1.001)); 11 System.out.println(Math.floor(-1.001)); 12 13 System.out.println(Math.round(1.54)); 14 15 System.out.println(Math.sqrt(9.0)); 16 17 System.out.println(Math.random()); 18 int a=2; 19 int b=7; 20 int num=a+(int)(Math.random()*(b-a+1)); 21 System.out.println("num="+ num); 22 23 System.out.println(Math.max(1.0,7.8)); 24 System.out.println(Math.min(12l,78l)); 25 26 } 27 }
结果:
10 10 16 0.0625 2.0 -2.0 2 3.0 0.2695117759347122 num=7 7.8 12
标签:code eth 结果 print out round stat sqrt java
原文地址:https://www.cnblogs.com/-xuewuzhijing-/p/13073234.html