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()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql镜像远程连接_docker 创
- 下一篇: 机器学习 导论_机器学习导论