日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java math 类_Java Math类静态双层(double d)示例

發布時間:2025/3/11 java 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java math 类_Java Math类静态双层(double d)示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

java math 類

數學班靜態雙層(雙D) (Math Class static double floor(double d))

  • This method is available in java.lang package.

    此方法在java.lang包中可用。

  • In this method if the value of the given positive argument after decimal point is 0 or greater than 0 so in that case it returns the same number before decimal point else if the value of the given negative argument after decimal point is greater than 0 so it returns (the same number +1) before decimal point.

    在此方法中,如果給定的正參數的小數點后的值是0或大于0,那么在這種情況下,它在小數點前返回相同的數字,否則,如果給定的負參數的值后小數點后大于0,則它在小數點前返回(相同的數字+1)。

  • This is a static method so this method is accessible with the class name too.

    這是一個靜態方法,因此也可以使用類名訪問此方法。

  • The return type of this method is double that means it returns the greatest floating-point value of the given argument and the argument value may be less than or equal to the given argument.

    此方法的返回類型為double,這意味著它將返回給定參數的最大浮點值,并且參數值可能小于或等于給定參數。

  • In this method, we pass only one parameter as an argument in the method of Math class.

    在此方法中,我們僅將一個參數作為參數傳遞給Math類的方法。

  • This method does not throw any exception.

    此方法不會引發任何異常。

Syntax:

句法:

public static double floor(double d){}

Parameter(s):

參數:

double d – A double value whose greatest floating-poin value to be found.

double d-一個雙精度值,其最大浮點值將被找到。

Note:

注意:

  • If we pass "NaN", it returns "NaN".

    如果我們傳遞“ NaN”,則返回“ NaN”。

  • If we pass a positive infinity, it returns the same i.e. a positive infinity.

    如果我們傳遞一個正無窮大,它將返回相同的值,即一個正無窮大。

  • If we pass a negative infinity, it returns the same i.e. a negative infinity.

    如果我們傳遞一個負無窮大,它將返回相同的值,即一個負無窮大。

  • If we pass 0 (-0 or 0), it returns the same.

    如果我們傳遞0(-0或0),則返回相同值。

Return value:

返回值:

The return type of this method is double, it returns the greatest floating-point value of the given value.

此方法的返回類型為double ,它返回給定值的最大浮點值。

Java程序演示floor(double d)方法的示例 (Java program to demonstrate example of floor(double d) method)

// Java program to demonstrate the example of floor(double d) // method of Math Classpublic class FloorMethod {public static void main(String[] args) {// Here we are declaring few variablesdouble d1 = 7.0 / 0.0;double d2 = -7.0 / 0.0;double d3 = 0.0;double d4 = -0.0;double d5 = -123.1;double d6 = 123.456;// Display previous value of d1,d2,d3,d4,d5 and d6 System.out.println(" Before implementing floor() so the value of d1 is :" + d1);System.out.println(" Before implementing floor() so the value of d2 is :" + d2);System.out.println(" Before implementing floor() so the value of d3 is :" + d3);System.out.println(" Before implementing floor() so the value of d4 is :" + d4);System.out.println(" Before implementing floor() so the value of d4 is :" + d5);System.out.println(" Before implementing floor() so the value of d4 is :" + d6);// Here , we will get (Infinity) because we are passing parameter // whose value is (infinity)System.out.println("After implementing floor() so the value of d1 is :" + Math.floor(d1));// Here , we will get (-Infinity) because we are passing parameter // whose value is (-infinity)System.out.println("After implementing floor() so the value of d2 is :" + Math.floor(d2));// Here , we will get (0.0) because we are passing parameter // whose value is (0.0)System.out.println("After implementing floor() so the value of d3 is :" + Math.floor(d3));// Here , we will get (-0.0) because we are passing parameter // whose value is (-0.0)System.out.println("After implementing floor() so the value of d4 is :" + Math.floor(d4));// Here , we will get (-124.0) because we are passing parameter // whose value is (-123.1)System.out.println("After implementing floor() so the value of d5 is :" + Math.floor(d5));// Here , we will get (123.0) because we are passing parameter // whose value is (123.456)System.out.println("After implementing floor() so the value of d6 is :" + Math.floor(d6));} }

Output

輸出量

E:\Programs>javac FloorMethod.javaE:\Programs>java FloorMethod Before implementing floor() so the value of d1 is :Infinity Before implementing floor() so the value of d2 is :-Infinity Before implementing floor() so the value of d3 is :0.0 Before implementing floor() so the value of d4 is :-0.0 Before implementing floor() so the value of d4 is :-123.1 Before implementing floor() so the value of d4 is :123.456After implementing floor() so the value of d1 is :Infinity After implementing floor() so the value of d2 is :-Infinity After implementing floor() so the value of d3 is :0.0 After implementing floor() so the value of d4 is :-0.0 After implementing floor() so the value of d5 is :-124.0 After implementing floor() so the value of d6 is :123.0

翻譯自: https://www.includehelp.com/java/math-class-static-double-floor-double-d-with-example.aspx

java math 類

總結

以上是生活随笔為你收集整理的java math 类_Java Math类静态双层(double d)示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。