math.nextup
数学课double nextUp(double do) (Math Class double nextUp(double do) )
This method is available in java.lang package.
此方法在java.lang包中可用。
This method is used to return the double floating-point number adjacent to the given argument (do) in the direction of the path of infinity.
此方法用于返回沿无穷大路径方向与给定参数( do )相邻的双浮点数。
This is a static method, so it is accessible with the class name too.
这是一个静态方法,因此也可以使用类名进行访问。
The return type of this method is double, it returns the double floating-point number adjacent to the given argument (do) which is nearby infinity.
此方法的返回类型为double ,它返回与无穷大附近的给定参数( do )相邻的双浮点数。
In this method, we pass only one parameter of double type which represents the initial or starting double floating-point value.
在此方法中,我们仅传递一个double类型的参数,该参数表示初始或起始double浮点值。
This method does not throw any exception.
此方法不会引发任何异常。
This is an overloaded method so two versions of this methods are available one is of double type argument and other is of float type argument and above we have discussed double argument type method.
这是一个重载方法,因此有两种版本的方法可用,一种是双 精度类型参数,另一种是浮点型参数,上面我们讨论了双参数类型方法。
Syntax:
句法:
public double nextUp(double do){
}
Parameter(s): do – which represents the initial or starting double floating point value.
参数: do –表示初始或起始双浮点值。
Note:
注意:
If we pass "NaN" (Not a Number), it returns the same i.e. "NaN".
如果我们传递“ NaN”(不是数字),则返回相同的值,即“ NaN”。
If we pass positive infinity, it returns the same i.e. positive infinity.
如果我们通过正无穷大,它将返回相同的值,即正无穷大。
If we pass 0 (-0 or 0), it returns "Double.MIN_VALUE".
如果我们传递0(-0或0),则返回“ Double.MIN_VALUE”。
Return value:
返回值:
The return type of this method is double, it returns the double floating point number adjacent to the given argument (do) which is nearby infinity.
此方法的返回类型为double ,它返回与给定参数(do)相邻且位于无穷大附近的double浮点数。
Java程序演示nextUp(double do)方法的示例 (Java program to demonstrate example of nextUp(double do) method)
// Java program to demonstrate the example of
// nextUp(double do) method of Math Class.
public class NextUpDoubleTypeMethod {
public static void main(String[] args) {
// declaring the variables
double d1 = -0.0;
double d2 = 0.0;
double d3 = -7.0 / 0.0;
double d4 = 7.0 / 0.0;
// displaying the values
System.out.println("d1: " + d1);
System.out.println("d2: " + d2);
System.out.println("d3: " + d3);
System.out.println("d4: " + d4);
// Here , we will get (Double.MIN_VALUE) because we are
// passing parameter whose value is (-0.0)
System.out.println("Math.nextUp(d1): " + Math.nextUp(d1));
// Here , we will get (Double.MIN_VALUE) and we are
// passing parameter whose value is (0.0)
System.out.println("Math.nextUp(d2): " + Math.nextUp(d2));
// Here , we will get (Infinity) and we are
// passing parameter whose value is (7.0/0.0)
System.out.println("Math.nextUp(d4): " + Math.nextUp(d4));
}
}
Output
输出量
E:\Programs>javac NextUpDoubleTypeMethod.java
E:\Programs>java NextUpDoubleTypeMethod
d1: -0.0
d2: 0.0
d3: -Infinity
d4: Infinity
Math.nextUp(d1): 4.9E-324
Math.nextUp(d2): 4.9E-324
Math.nextUp(d4): Infinity
翻译自: https://www.includehelp.com/java/math-class-static-double-nextup-double-do-with-example.aspx
math.nextup