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

歡迎訪問 生活随笔!

生活随笔

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

java

strictmath_Java StrictMath rint()方法与示例

發布時間:2025/3/11 java 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 strictmath_Java StrictMath rint()方法与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

strictmath

StrictMath類rint()方法 (StrictMath Class rint() method)

  • rint() Method is available in java.lang package.

    rint()方法在java.lang包中可用。

  • rint() Method is used to return the double type value and if the value of the given argument after decimal point is greater than 4 then the value is incremented by 1 before the decimal point is returned else if the value of the given argument after decimal point is less than or equal to 4 then the same value before the decimal point is returned.

    rint()方法用于返回雙精度類型值,如果小數點后給定參數的值大于4,則在返回小數點前將值加1,否則,如果小數點后給定參數的值如果小數點小于或等于4,則返回小數點前的相同值。

  • rint() Method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get any error.

    rint()方法是一個靜態方法,因此可以使用類名進行訪問,如果嘗試使用類對象訪問該方法,則不會出現任何錯誤。

  • rint() Method does not throw any exception.

    rint()方法不會引發任何異常。

Syntax:

句法:

public static double rint(double d);

Parameter(s):

參數:

  • double d – represents a double type value.

    double d –表示雙精度型值。

Return value:

返回值:

The return type of the method is double, it returns the double floating point number which will be equivalent to mathematical integer.

該方法的返回類型為double ,它返回等于數學整數的雙精度浮點數。

Note:

注意:

  • If we pass NaN, the method returns the NaN.

    如果傳遞NaN,則該方法返回NaN。

  • If we an infinity, the method returns the same (i.e. infinity).

    如果我們無窮大,則該方法將返回相同的值(即無窮大)。

  • If we pass an argument whose value after the decimal point is greater than 4, the method returns the value incremented by 1 before the decimal point.

    如果我們傳遞的參數的小數點后的值大于4,則該方法返回的值在小數點前增加1。

  • If we pass zero, the method returns the same value with the same sign.

    如果傳遞零,則該方法返回具有相同符號的相同值。

Example:

例:

// Java program to demonstrate the example of // rint(double d) method of StrictMath Class.public class Rint {public static void main(String[] args) {// variable declarationsdouble d1 = -0.0;double d2 = 0.0;double d3 = -1.0 / 0.0;double d4 = 1.0 / 0.0;double d5 = 1234.56;double d6 = 1234.12;// Here , we will get (-0.0) because we are // passing parameter whose value is (-0.0)System.out.println("StrictMath.rint(d1): " + StrictMath.rint(d1));// Here , we will get (0.0) and we are // passing parameter whose value is (0.0)System.out.println("StrictMath.rint(d2): " + StrictMath.rint(d2));// Here , we will get (-Infinity) and we are // passing parameter whose value is (-Infinity)System.out.println("StrictMath.rint(d3): " + StrictMath.rint(d3));// Here , we will get (Infinity) and we are// passing parameter whose value is (Infinity)System.out.println("StrictMath.rint(d4): " + StrictMath.rint(d4));// Here , we will get (1235.0) and we are // passing parameter whose value is (1234.56)System.out.println("StrictMath.rint(d5): " + StrictMath.rint(d5));// Here , we will get (1234.0) and we are // passing parameter whose value is (1234.12)System.out.println("StrictMath.rint(d6): " + StrictMath.rint(d6));} }

Output

輸出量

StrictMath.rint(d1): -0.0 StrictMath.rint(d2): 0.0 StrictMath.rint(d3): -Infinity StrictMath.rint(d4): Infinity StrictMath.rint(d5): 1235.0 StrictMath.rint(d6): 1234.0

翻譯自: https://www.includehelp.com/java/strictmath-rint-method-with-example.aspx

strictmath

總結

以上是生活随笔為你收集整理的strictmath_Java StrictMath rint()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

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