java math 類_Java Math類靜態長輪(double d)示例

java math 類

數學課靜態長回合(雙D) (Math Class static long round(double d) )

  • This method is available in java.lang package.

    此方法在java.lang包中可用。

  • This method is used to return the closest long value to the given argument.

    此方法用于將最接近的long值返回給定參數。

  • This is a static method, it is accessible with the class name too.

    這是一個靜態方法,也可以使用類名進行訪問。

  • The return type of this method is long, it returns the long type number which will be converted from double floating to long by adding 1/2 of the given argument.

    此方法的返回類型為long ,它返回long類型號,通過添加給定參數的1/2可以將其從double浮點數轉換為long類型。

  • In this method, we pass only one parameter of a double type value.

    在此方法中,我們僅傳遞一個double類型值的參數。

  • If the value of the given argument after the 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 the decimal point is less than or equal to 4 then the same value before the decimal point is returned.

    如果小數點后給定參數的值大于4,則在返回小數點前將值加1;否則,如果小數點后給定參數的值小于或等于4,則相同返回小數點前的值。

  • This method does not throw any exception.

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

Syntax:

句法:

    public static long round(double d){
}

Parameter(s): d – a double value whose closest to long value to be found.

參數: d –一個雙精度值,其最接近要找到的long值。

Note:

注意:

  • If we pass "NaN" (Not a Number), it returns 0.

    如果傳遞“ NaN”(非數字),則返回0。

  • If we pass negative infinity, it returns the "Long.MIN_VALUE".

    如果我們傳遞負無窮大,它將返回“ Long.MIN_VALUE”。

  • If we pass positive infinity, it returns the "Long.MAX_VALUE".

    如果我們傳遞正無窮大,它將返回“ Long.MAX_VALUE”。

  • If we pass the value which is less than or equal to "Long.MIN_VALUE", it returns "Long.MIN_VALUE".

    如果傳遞的值小于或等于“ Long.MIN_VALUE”,則返回“ Long.MIN_VALUE”。

  • If we pass the value which is greater than or equal to "Long.MAX_VALUE", it returns "Long.MAX_VALUE".

    如果傳遞的值大于或等于“ Long.MAX_VALUE”,則返回“ Long.MAX_VALUE”。

Return value:

返回值:

The return type of this method is long, it returns a long value which is the closest to long value of given parameter.

此方法的返回類型為long ,它返回一個long值,該值最接近給定參數的long值。

Java程序演示round(double d)方法的示例 (Java program to demonstrate example of round(double d) method)

// Java program to demonstrate the example of 
// round(double d) method of Math Class.
public class RoundMethod {
public static void main(String[] args) {
// declaring the variables
double d1 = -1.0 / 0.0;
double d2 = 1.0 / 0.0;
double d3 = 1234.56;
double d4 = 1234.42;
// Here , we will get (Long.MIN_VALUE) and we are 
// passing parameter whose value is (-Infinity)
System.out.println("Math.round(d1): " + Math.round(d1));
// Here , we will get (Long.MAX_VALUE) and we are 
// passing parameter whose value is (Infinity)
System.out.println("Math.round(d2): " + Math.round(d2));
// Here , we will get (1235) and we are 
// passing parameter whose value is (1234.56)
System.out.println("Math.round(d3): " + Math.round(d3));
// Here , we will get (1234) and we are 
// passing parameter whose value is (1234.12)
System.out.println("Math.round(d4): " + Math.round(d4));
}
}

Output

輸出量

E:\Programs>javac RoundMethod.java
E:\Programs>java RoundMethod
Math.round(d1): -9223372036854775808
Math.round(d2): 9223372036854775807
Math.round(d3): 1235
Math.round(d4): 1234

翻譯自: https://www.includehelp.com/java/math-class-static-long-round-double-d-with-example.aspx

java math 類

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

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

相關文章

C——求平均成績

Problem Description 假設一個班有n(n<50)個學生&#xff0c;每人考m(m<5)門課&#xff0c;求每個學生的平均成績和每門課的平均成績&#xff0c;并輸出各科成績均大于等于平均成績的學生數量。 Input 輸入數據有多個測試實例&#xff0c;每個測試實例的第一行包括兩個…

依賴、關聯、聚合、組合還有泛化的關系(轉載)

依賴、關聯、聚合、組合還有泛化的關系 此文為轉載文章:http://zjzkiss.cnblogs.com/世界是普遍聯系的&#xff0c;因此程序世界中的類&#xff0c;也不可能是孤立的。UML為我們定義了它們之間的關系&#xff0c;就是&#xff1a;依賴、關聯、聚合、組合還有泛化。 泛化關系比…

神奇的LINQ ---可以通過對象來查詢數據

摘要&#xff1a; linq:在一個新項目里面要用這個技術&#xff0c;然后自己拿起書看了下&#xff0c;記錄下自己的新發現&#xff0c;只適合簡單入門的新童鞋看呀&#xff01;&#xff01;&#xff01; 結論&#xff1a; linq是對象領域與數據領域的一個橋梁。 為什么會出現Lin…

java math.cos_Java Math類靜態double cos(double d)示例

java math.cos數學類靜態雙cos(double d) (Math Class static double cos(double d)) This method is available in java.lang package. 此方法在java.lang包中可用。 This method is used to return the trigonometric cosine of an angle of the given parameter in the meth…

web安全---SSRF漏洞

簡介 SSRF&#xff1a;服務器請求偽造&#xff0c;是一種攻擊者構造形成由服務端發起請求 的一個安全漏洞。一般情況下&#xff0c;SSRF攻擊的目標是從外網無法訪問的內部系統&#xff08;正是因為它是由服務端發起的&#xff0c;所以它能夠請求到與它相連而與外網隔離的內部系…

集合——對象數組(引用數據類型數組)

案例&#xff1a;我有5個學生&#xff0c;請把這個5個學生的信息存儲到引用數據類型數組中&#xff0c;并遍歷數組&#xff0c;獲取得到每一個學生的信息。 思路分析&#xff1a;首先&#xff0c;想要創建學生對象&#xff0c;就得有學生這個類&#xff0c;所以&#xff0c;首…

提升應用視覺Android效果的10個UI技巧

在Android應用開發中&#xff0c;風格和設計或許不是最關鍵的要素&#xff0c;但它們在決定Android應用成功與否上確實扮演重要的角色。以下是10個Android應用的UI設計技巧&#xff0c;還有個附加技巧&#xff0c;能夠提供你的Android應用的視覺吸引力。 技巧1&#xff1a;使用…

kotlin中判斷字符串_Kotlin程序查找字符串中字符的頻率

kotlin中判斷字符串Given a string and a character, we have to find the frequency of the character in the string. 給定一個字符串和一個字符&#xff0c;我們必須找到字符串中字符的頻率。 Example: 例&#xff1a; Input:string "IncludeHelp"character to…

OD使用

0x01 功能界面 序號1是匯編代碼對應的地址窗口序號2是匯編對應的十六進制機器碼窗口序號3是反匯編窗口序號4是反匯編代碼對應的注釋信息窗口序號5是寄存器信息窗口序號6是當前執行到的反匯編代碼的信息窗口序號7是數據所在的地址序號8是數據的十六進制編碼信息&#xff0c;序號…

windows mobile 開發總結--菜單

在開發時經常要創建菜單&#xff0c;并且動態顯示和隱藏菜單或者是某個子菜單。以下就是實現的方法&#xff1a; 1。創建并顯示菜單,先在資源里添加菜單&#xff0c;然后如下代碼 SHMENUBARINFO mbi; ZeroMemory(&mbi, sizeof(SHMENUBARINFO)); mbi.cbSizesizeof(SHMENUBAR…

Java——集合的概述

* A&#xff1a;集合的由來* 數組是容器&#xff0c;集合也是容器* 數組的弊端&#xff1a;數組的長度是固定的&#xff0c;當添加的元素超過了數組的長度時&#xff0c;需要對數組重新定義&#xff0c;太麻煩* Java內部給我們提供了集合類&#xff0c;可以存儲任意對象&#x…

排序算法中平均時間復雜度_操作系統中的作業排序(算法,時間復雜度和示例)...

排序算法中平均時間復雜度作業排序 (Job sequencing) Job sequencing is the set of jobs, associated with the job i where deadline di > 0 and profit pi > 0. For any job i the profit is earned if and only if the job is completed by its deadline. To complet…

python---文件處理

0x01 打開一個文件 python中內置了文件對象&#xff0c;通過open()函數就可以制定模式打開指定文件&#xff0c;并創建文件對象。該函數的格式如下&#xff1a; open(file[,moder[,buffering-1]])file&#xff1a;指定要打開或創建的文件名稱&#xff0c;如果該文件不存在當前…

簡易而又靈活的Javascript拖拽框架(四)

一、開篇 似乎拖拽已經被寫爛了&#xff0c;沒得寫的了&#xff0c;可是我這次又來了&#xff5e; 上一次寫的是跨列拖放&#xff0c;這次我要帶給大家的是跨頁拖放。 可以到這里來看看效果&#xff1a;示例效果 說明&#xff1a;1、如果將方框拖動到頁簽上立刻釋放掉的話&…

Java——集合的基本功能測試

* 1,boolean add<E,e> 添加* 確保此 collection 包含指定的元素&#xff08;可選操作&#xff09;。* 參數&#xff1a;e - 確定此 collection 中是否存在的元素。E - 代表Object類&#xff0c;說明該add可以添加任何對象&#xff0c;任意對象都是Object的子類對象&…

《那些年啊,那些事——一個程序員的奮斗史》——78

招人風波之后&#xff0c;就很少見武總往18樓跑了&#xff0c;大部分時間都是坐在22樓的隔間。而武總對段伏櫪的抱怨&#xff0c;也僅僅只有那次&#xff0c;后來就再也沒有提過。對于段伏櫪而言&#xff0c;還要不要招新人&#xff0c;后續如何去招新人&#xff0c;已經不是自…

python---異常處理結構

python中提供了很多不同形式的異常處理結構&#xff0c;其基本思路都是先嘗試執行代碼&#xff0c;再處理可能發生的錯誤。 try…except… 在python異常處理結構中&#xff0c;try…except…使用最為頻繁&#xff0c;其中try子句中的代碼塊為可能引發異常的語句&#xff0c;e…

用css網站布局之十步實錄 (轉載)

第一步&#xff1a;規劃網站http://www.52css.com/article.asp?id175 第二步&#xff1a;創建html模板及文件目錄等http://www.52css.com/article.asp?id176 第三步&#xff1a;將網站分為五個div 網頁基本布局http://www.52css.com/article.asp?id177 第四步&#xff1a;網…

Java——集合轉數組并對其進行遍歷

* A&#xff1a;集合的遍歷* 其實就是以此獲取集合中的每一個元素* B&#xff1a;案例* 把集合轉成數組&#xff0c;可以實現集合的遍歷* public Object[] toArray() 按適當順序&#xff08;從第一個到最后一個元素&#xff09;返回包含此列表中所有元素的數組。…

魚油賬號記錄程序(續) - 零基礎入門學習Delphi39

魚油賬號記錄程序&#xff08;續&#xff09; 讓編程改變世界 Change the world by program 課件同上一講&#xff0c;這一講主要演示編程操作和修改程序&#xff01; [buy] 獲得所有教學視頻、課件、源代碼等資源打包 [/buy] [Downlink hrefhttp://kuai.xunlei.com/d/LDKX…