zoukankan      html  css  js  c++  java
  • java基础 Math

     1 package cn.mantishell.day08.demo04;
     2 
     3 /**
     4  * java.util.Math类是数学相关的工具类,里面提供类大量的静态方法,完成与数学运算相关的操作
     5  *
     6  * public static double abs(double num);获取绝对值
     7  * public static double ceil(double num);向上取整
     8  * public static double floor(double num);向下取整
     9  * public static long round(double num);四舍五入
    10  */
    11 public class Demo03Math {
    12     public static void main(String[] args) {
    13         //获取绝对值
    14         System.out.println(Math.abs(-2.5));//2.5
    15         //向上取整
    16         System.out.println(Math.ceil(3.9));//4.0
    17         System.out.println(Math.ceil(3.1));//4.0
    18         System.out.println(Math.ceil(3.0));//3.0
    19 
    20         System.out.println(Math.floor(10.9));
    21 
    22         System.out.println(Math.round(2.6));
    23     }
    24 }
  • 相关阅读:
    flask强大的三方组件flask-Migrate
    FTP和HTTP
    MD5-JS加密
    使用websocket实现单聊和多聊
    Flask上下文管理
    python中的with用法
    如何判断一个对象是可调用对象
    缓存
    websocket与http
    csrf
  • 原文地址:https://www.cnblogs.com/mantishell/p/11681058.html
Copyright © 2011-2022 走看看