java中的starts_Java Math类静态double nextAfter(double starts,double direction)示例
java中的starts
數(shù)學(xué)類靜態(tài)double nextAfter(雙向啟動(dòng),雙向) (Math Class static double nextAfter(double starts , double directions) )
This method is available in java.lang package.
此方法在java.lang包中可用。
This method is used to return the double floating-point number adjacent to the first parameter (starts) in the direction of the second parameter (directions).
此方法用于在第二個(gè)參數(shù)(方向)的方向上返回與第一個(gè)參數(shù)相鄰的雙浮點(diǎn)數(shù)(起始)。
Let suppose both arguments passed in the method are equivalent so in that case the second parameter is returned.
假設(shè)在方法中傳遞的兩個(gè)參數(shù)都相等,那么在這種情況下將返回第二個(gè)參數(shù)。
This is a static method, so it is accessible with the class name too.
這是一個(gè)靜態(tài)方法,因此也可以使用類名進(jìn)行訪問(wèn)。
The return type of this method is double, it returns the double floating-point number adjacent to start in the direction of the second argument.
此方法的返回類型為double ,它返回第二個(gè)參數(shù)方向上與start相鄰的double浮點(diǎn)數(shù)。
In this method, we pass two parameters of double type so the first parameter represents the initial or starting floating-point value and the second parameter represents the value denoting which of the given first parameter neighbor (Starts neighbor) or start is returned.
在此方法中,我們傳遞了兩個(gè)雙精度類型的參數(shù),因此第一個(gè)參數(shù)表示初始或起始浮點(diǎn)值,第二個(gè)參數(shù)表示表示返回給定的第一個(gè)參數(shù)鄰居(起點(diǎn)鄰居)或起點(diǎn)的值。
This method does not throw any exception.
此方法不會(huì)引發(fā)任何異常。
Syntax:
句法:
public static double nextAfter(double starts , double directions){}Parameter(s):
參數(shù):
starts – represents the initial or starting floating-point value.
starts –表示初始或起始浮點(diǎn)值。
directions – represents the value denoting which of the given first parameter neighbor (starts neighbor).
directions –代表一個(gè)值,該值表示給定的第一個(gè)參數(shù)鄰居( 起始鄰居)。
Return value:
返回值:
The return type of this method is double, it returns the double floating-point number adjacent to the first parameter (starts) in the direction of second parameter (directions).
這種方法的返回類型是雙 ,它在第二個(gè)參數(shù)( 方向 )的方向返回鄰近第一參數(shù)( 首發(fā) )的雙浮點(diǎn)數(shù)。
Note:
注意:
If we pass "NaN" (Not a Number), it returns the same i.e. "NaN".
如果我們傳遞“ NaN”(不是數(shù)字),則返回相同的值,即“ NaN”。
If we pass the same value in both of the parameters, it returns the same value.
如果我們?cè)趦蓚€(gè)參數(shù)中傳遞相同的值,它將返回相同的值。
If we pass "Double.MIN_VALUE" as the first parameter and second parameter holds another value, it returns smaller value i.e. the same value is with the same sign as the first parameter.
如果我們將“ Double.MIN_VALUE”作為第一個(gè)參數(shù)傳遞,而第二個(gè)參數(shù)包含另一個(gè)值,則它將返回較小的值,即,與第一個(gè)參數(shù)相同的值帶有相同的符號(hào)。
If we pass infinity as first parameter and second parameter holds another value, it returns the "Double.MAX_VALUE" with the same sign as the first parameter.
如果我們將無(wú)窮大作為第一個(gè)參數(shù)傳遞而第二個(gè)參數(shù)包含另一個(gè)值,則它將返回與第一個(gè)參數(shù)具有相同符號(hào)的“ Double.MAX_VALUE”。
If we pass "Double.MAX_VALUE" as the first parameter and second parameter holds another value, it returns the largest value with the same sign as the first parameter.
如果我們將“ Double.MAX_VALUE”作為第一個(gè)參數(shù)傳遞,而第二個(gè)參數(shù)保留另一個(gè)值,則它將返回與第一個(gè)參數(shù)具有相同符號(hào)的最大值。
Java程序演示nextAfter(double starts,雙向)方法的示例 (Java program to demonstrate example of nextAfter(double starts , double directions) method)
// Java program to demonstrate the example of // nextAfter(double starts , double directions) method of Math Class.public class NextAfterDoubleTypeMethod {public static void main(String[] args) {// declaring the variablesdouble d1 = -2.6;double d2 = 0.0;double d3 = -0.6;double d4 = 7.0 / 0.0;// displaying the valuesSystem.out.println("d1: " + d1);System.out.println("d2: " + d2);System.out.println("d3: " + d3);System.out.println("d4: " + d4);// Here , we will get (-2.5 (approx.)) because we are passing // parameter whose value is (-2.6,0.0)System.out.println("Math.nextAfter(d1,d2):" + Math.nextAfter(d1, d2));// Here , we will get (2.6) and we are passing parameter // whose value is (0.0,-2.6)System.out.println("Math.nextAfter(d2,d1):" + Math.nextAfter(d2, d1));// Here , we will get (Double.MAX_VALUE) and we are passing parameter// whose value is (7.0/0.0,0.0)System.out.println("Math.nextAfter(d4,d2):" + Math.nextAfter(d4, d2));// Here , we will get (largest value) and we are passing parameter // whose value is (0.0,7.0/0.0)System.out.println("Math. nextAfter(d2,d4):" + Math.nextAfter(d2, d4));} }Output
輸出量
E:\Programs>javac NextAfterDoubleTypeMethod.javaE:\Programs>java NextAfterDoubleTypeMethod d1: -2.6 d2: 0.0 d3: -0.6 d4: Infinity Math.nextAfter(d1,d2):-2.5999999999999996 Math.nextAfter(d2,d1):-4.9E-324 Math.nextAfter(d4,d2):1.7976931348623157E308 Math. nextAfter(d2,d4):4.9E-324翻譯自: https://www.includehelp.com/java/math-class-static-double-nextafter-double-starts-double-directions-with-example.aspx
java中的starts
總結(jié)
以上是生活随笔為你收集整理的java中的starts_Java Math类静态double nextAfter(double starts,double direction)示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Java String compareT
- 下一篇: bitcount方法详解_Java Lo