java中的starts_Java Math類靜態double nextAfter(double starts,double direction)示例

java中的starts

數學類靜態double nextAfter(雙向啟動,雙向) (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).

    此方法用于在第二個參數(方向)的方向上返回與第一個參數相鄰的雙浮點數(起始)。

  • Let suppose both arguments passed in the method are equivalent so in that case the second parameter is returned.

    假設在方法中傳遞的兩個參數都相等,那么在這種情況下將返回第二個參數。

  • 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 start in the direction of the second argument.

    此方法的返回類型為double ,它返回第二個參數方向上與start相鄰的double浮點數。

  • 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.

    在此方法中,我們傳遞了兩個雙精度類型的參數,因此第一個參數表示初始或起始浮點值,第二個參數表示表示返回給定的第一個參數鄰居(起點鄰居)或起點的值。

  • This method does not throw any exception.

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

Syntax:

句法:

    public static double nextAfter(double starts , double directions){
}

Parameter(s):

參數:

  • starts – represents the initial or starting floating-point value.

    starts –表示初始或起始浮點值。

  • directions – represents the value denoting which of the given first parameter neighbor (starts neighbor).

    directions –代表一個值,該值表示給定的第一個參數鄰居( 起始鄰居)。

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).

這種方法的返回類型是雙 ,它在第二個參數( 方向 )的方向返回鄰近第一參數( 首發 )的雙浮點數。

Note:

注意:

  • If we pass "NaN" (Not a Number), it returns the same i.e. "NaN".

    如果我們傳遞“ NaN”(不是數字),則返回相同的值,即“ NaN”。

  • If we pass the same value in both of the parameters, it returns the same value.

    如果我們在兩個參數中傳遞相同的值,它將返回相同的值。

  • 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”作為第一個參數傳遞,而第二個參數包含另一個值,則它將返回較小的值,即,與第一個參數相同的值帶有相同的符號。

  • 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.

    如果我們將無窮大作為第一個參數傳遞而第二個參數包含另一個值,則它將返回與第一個參數具有相同符號的“ 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”作為第一個參數傳遞,而第二個參數保留另一個值,則它將返回與第一個參數具有相同符號的最大值。

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 variables
double d1 = -2.6;
double d2 = 0.0;
double d3 = -0.6;
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 (-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.java
E:\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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/540467.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/540467.shtml
英文地址,請注明出處:http://en.pswp.cn/news/540467.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Python 核心編程(第二版)——條件和循環

Python 中的 if 子句由三部分組成: 關鍵字本身,用于判斷結果真假的條件表達式, 以及當表達式為真或者非零時執行的代碼塊。if 語句的語法如下: if expression: expr_true_suite 單個 if 語句可以通過使用布爾操作符 and , or 和 not實現多重判斷條件或…

[轉載] 【python魔術方法】迭代器(__iter__和__next__)

參考鏈接: Python __iter __()和__next __()| 將對象轉換為迭代器 文章目錄 __iter__ 和 __next__真正的迭代器總結 python里面有很多的以__開始和結尾的函數,利用它們可以完成很多復雜的邏輯代碼,而且提高了代碼的簡潔性,本文主…

Silverlight 異步單元測試

Silverlight 中的很多操作都是異步的,很多情況下要求單元測試也是異步的,但是介紹異步單元測試的文檔很少。通過對 Silverlight Toolkit 中的 Microsoft.Silverlight.Testing 和 Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight 這兩個文件…

網絡拓撲 令牌環網 以太網_以太網連接中網絡拓撲的類型及其框架 以太網技術...

網絡拓撲 令牌環網 以太網A topology explains how physically the network is designed or what is the structure of the network. These designs are both physical and logical. There are many network topologies 4 like Bus, Star, Ring, and Mesh. But only two types …

Wafer晶圓封裝工藝介紹

芯片封裝的目的(The purpose of chip packaging): 芯片上的IC管芯被切割以進行管芯間連接,通過引線鍵合連接外部引腳,然后進行成型,以保護電子封裝器件免受環境污染(水分、溫度、污染物等)&…

[轉載] Python中的解析式和生成器表達式

參考鏈接: Python | 生成器表達式 解析式和生成器表達式 列表解析List Comprehension 語法 [返回值 for 元素 in 可迭代對象 if 條件]使用中括號[],內部是for循環,if條件語句可選,會返回一個新的列表 列表解析試優點 編譯器會優化&…

java 數字字母進位_使用帶有進位的8085微處理器將兩個8位數字相乘

java 數字字母進位Problem statement: 問題陳述: Multiplication of two 8 bits numbers using 8085 microprocessor with carry. 使用帶有進位的8085微處理器將兩個8位數字相乘。 Algorithm: 算法: Load HL pair with initial data using LHLD comma…

[轉載] Python3.0中普通方法、類方法和靜態方法的比較

參考鏈接: Python中的類方法與靜態方法 一、語法區別 剛接觸Python中的面向對象,對于類方法和靜態方法難以區分,通過查找知乎、CSDN論壇,廢了好大的勁思路才逐漸明朗,所以就總結順便分享一下。 首先開始編輯代碼 # 普…

iOS:個人淺談工廠模式

一、什么是工廠方法? 正式的解釋是:在基類中定義創建對象的一個接口,讓子類決定實例化哪個類。工廠方法讓一個類的實例化延遲到子類中進行。工廠方法要解決的問題是對象的創建時機,它提供了一種擴展的策略,很好地符合了…

scanf 輸入十六進制_使用C語言中的scanf()在字符變量中輸入十進制,八進制和十六進制值...

scanf 輸入十六進制Here, we will declare an unsigned char variable and input different formats value like decimal format, octal format and hexadecimal format. 在這里,我們將聲明一個無符號的char變量,并輸入不同格式的值,例如十進…

[轉載] Python中pass的作用

參考鏈接: 如何在Python中編寫空函數?請使用 pass語句 空語句 do nothing保證格式完整保證語義完整 以if語句為例,在c或c/java中: if(true) ; //do nothing else { //do something } 對應于python就要這樣寫&#xff…

wrf 嵌套網格作用_在網格系統中使用響應列,嵌套列和偏移列 引導程序

wrf 嵌套網格作用介紹 (Introduction) In the previous article, we have learnt what is grid and grid system and how it works? Now, we will learn about how Responsive column, Nesting Columns and Offset Columns works and how to use them? If you have any doubt…

[看書筆記]《深入java虛擬機》——java體系結構(二)

java虛擬機的三種含義: - 抽象的規范 - 一個具體的實現 - 一個運行中的虛擬機實例 ---------------------java虛擬機的生命周期: java虛擬機實例的天職就是負責運行一個java程序。 啟動一個java程序,一個虛擬機實例誕生了;程序關閉…

[轉載] 【零基礎學爬蟲】python中的yield詳解

參考鏈接: 什么時候在Python中使用yield而不是return python中的yield功能比較強大,什么意思呢?如果一個函數f內使用了yield關鍵詞,那么該函數就可以這樣使用: for item in f(***): **** 也就是包含yield關鍵詞的函…

全新的membership框架Asp.net Identity(1)——.Net membership的歷史

在Asp.net上,微軟的membershop框架經歷了Asp.net membership到Asp.net simple membership,再到現在的Asp.net Identity. 每一次改變,都使得驗證框架更加的適應變化和可定制。這篇文章是Asp.net Identity系列的開篇,主要就membersh…

c語言100位整數變量聲明_C ++程序動態聲明一個整數變量并打印其內存地址

c語言100位整數變量聲明Here, we will learn how we can declare an integer variable dynamically and how to print address of declared memory block? 在這里,我們將學習如何動態聲明整數變量,以及如何打印聲明的內存塊的地址? In C pr…

[轉載] python 函數返回多個值

參考鏈接: 在Python中返回多個值 (廖雪峰Python教程學習筆記) 函數體內部的語句在執行時,一旦執行到return,函數就執行完畢,并將結果返回。 如果沒有return語句,函數執行完畢后也會返回結果…

二.編寫第一個c#程序(注釋,命名空間,類,Main方法,標識符,關鍵字,輸入,輸出語句,)...

復習編寫一個控制臺應用程序,目標是在控制臺輸出“Hello World” 1.第一步,打開Visual Studio 2012以上版本(我用的是VS 2015),打開完成后出現以下界面 2.第二步,這時候就要新建一個解決方案了,創建解決方案可以直接點…

[轉載] Python中定義函數,循環語句,條件語句

參考鏈接: Python中的局部函數 由于日常程序流中主要是三種結構:順序,循環,條件,且往往需要自定義函數再調用, 因此今天想學習一下Python中關于定義函數、循環語句和條件語句的寫法。 1.定義函數 區…

node oauth2驗證_如何設置和使用護照OAuth Facebook身份驗證(第1部分)| Node.js

node oauth2驗證In my last articles, we looked at the implementation of the passport-local authentication strategy. We also looked at the various requirements to get started with the login form. 在上一篇文章中,我們介紹了護照本地身份驗證策略的實現…