java-Math類

來源:互聯網
上載者:User

標籤:blog   div   main   int   成員方法   次方   out   產生   結果   

package com.day10.Math類;

public class DemoMath {

  /**
  * @param args
  * 見對象(Math類概述和方法使用)
  * A:Math類概述
  *    Math 類包含用於執行基本數學運算的方法,如初等指數、對數、平方根和三角函數。
  * B:成員方法
  *    public static int abs(int a)
  *    public static double ceil(double a)
  *    public static double floor(double a)
  *    public static int max(int a,int b) min自學
  *    public static double pow(double a,double b)
  *    public static double random()
  *    public static int round(float a) 參數為double的自學
  *    public static double sqrt(double a)
  */
  public static void main(String[] args) {
    System.out.println(Math.PI);
    System.out.println(Math.abs(-10));//取絕對值

    System.out.println(Math.ceil(12.3));//13.0,ceil天花板,向上取整
    System.out.println(Math.floor(12.9));//12.0,floor地板,向下取整,結果返回double
    System.out.println(Math.max(2,4));//4
    System.out.println(Math.min(2,4));//2
    System.out.println(Math.pow(2,3));//8.0,2的三次方
    System.out.println(Math.random());//產生0.0到1.0之間的隨機小數,[0.0,1.0)
    System.out.println(Math.round(2.4));//2,四捨五入的意思
    System.out.println(Math.sqrt(9));//3.0,開根號

  }

}

java-Math類

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.