MathTest.java 815 B

1234567891011121314151617181920212223
  1. package course.api.math;
  2. /**
  3. * @author WanJl
  4. * @version 1.0
  5. * @title MathTest
  6. * @description
  7. * @create 2026/7/27
  8. */
  9. public class MathTest {
  10. public static void main(String[] args) {
  11. System.out.println("π:"+Math.PI);
  12. System.out.println("获取绝对值:"+Math.abs(-6));
  13. System.out.println("获取最大值:"+Math.max(15,7));
  14. System.out.println("获取最小值:"+Math.min(15,7));
  15. System.out.println("2的10次方:"+Math.pow(2,10));
  16. System.out.println("开根号:"+Math.sqrt(16));
  17. System.out.println("向上取整:"+Math.ceil(3.2));
  18. System.out.println("向下取整:"+Math.floor(3.2));
  19. System.out.println("四舍五入:"+Math.round(3.6));
  20. System.out.println("[0.0 , 1.0]随机数:"+Math.random());
  21. }
  22. }