strictmath_Java StrictMath sqrt()方法與示例

strictmath

StrictMath類sqrt()方法 (StrictMath Class sqrt() method)

  • sqrt() Method is available in java.lang package.

    sqrt()方法在java.lang包中可用。

  • sqrt() Method is used to find the square root of the given parameter in the method. Here, "sqrt" stands for square root

  • sqrt() 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.
  • sqrt() Method does not throw any exception at the time of finding the square root of the given number.
  • sqrt()方法用于查找方法中給定參數的平方根。 在這里, “ sqrt”代表平方根

  • sqrt()方法是靜態方法,因此可以使用類名進行訪問,如果嘗試使用類對象訪問該方法,則不會收到任何錯誤。
  • sqrt()方法在查找給定數字的平方根時不會引發任何異常。

Syntax:

句法:

    public static double sqrt(double d);

Parameter(s):

參數:

  • double d – represents for which we have to find the square root.

    double d –代表我們必須找到其平方根。

Return value:

返回值:

The return type of the method is double, it returns the square root of the given parameter.

該方法的返回類型為double ,它返回給定參數的平方根。

Note:

注意:

  • If we pass NaN, the method returns the same (i.e. NaN).

    如果我們通過NaN,則該方法返回相同的值(即NaN)。

  • If we pass zero, the method returns the same value with the same sign.

    如果傳遞零,則該方法返回具有相同符號的相同值。

  • If we pass an argument positive infinity, the method returns the same.

    如果我們傳遞參數正無窮大,則該方法將返回相同的結果。

Example:

例:

// Java program to demonstrate the example of sqrt(double d) 
// method of StrictMath class.
public class Sqrt {
public static void main(String[] args) {
// variable declarations
double d1 = -0.0;
double d2 = 0.0;
double d3 = -7.0 / 0.0;
double d4 = 7.0 / 0.0;
double d5 = 1000.0;
double d6 = -1000.0;
// Display previous value of d1,d2,d3,d4,d5 and d6
System.out.println("d1: " + d1);
System.out.println("d2: " + d2);
System.out.println("d3: " + d3);
System.out.println("d4: " + d4);
System.out.println("d5: " + d5);
System.out.println("d6: " + d6);
/*Here , we will get (-0.0) because we are passing parameter (-0.0) */
System.out.println("StrictMath.sqrt(d1): " + StrictMath.sqrt(d1));
// Here , we will get (0.0) because we are passing parameter 
// (0.0) so the square root is the same
System.out.println("StrictMath.sqrt(d2): " + StrictMath.sqrt(d2));
// Here , we will get (NaN) because we are passing parameter 
// (-7.0/0.0) so the square root is (-Infinity)
System.out.println("StrictMath.sqrt(d3): " + StrictMath.sqrt(d3));
// Here , we will get (Infinity) because we are passing 
// parameter (7.0/0.0) so the square root is (Infinity)
System.out.println("StrictMath.sqrt(d4): " + StrictMath.sqrt(d4));
// Here , we will get (square root of given argument) because 
// we are passing parameter (1000.0) 
System.out.println("StrictMath.sqrt(d5): " + StrictMath.sqrt(d5));
// Here , we will get (NaN) because we are passing parameter 
// (-1000.0) 
System.out.println("StrictMath.sqrt(d6): " + StrictMath.sqrt(d6));
}
}

Output

輸出量

d1: -0.0
d2: 0.0
d3: -Infinity
d4: Infinity
d5: 1000.0
d6: -1000.0
StrictMath.sqrt(d1): -0.0
StrictMath.sqrt(d2): 0.0
StrictMath.sqrt(d3): NaN
StrictMath.sqrt(d4): Infinity
StrictMath.sqrt(d5): 31.622776601683793
StrictMath.sqrt(d6): NaN

翻譯自: https://www.includehelp.com/java/strictmath-sqrt-method-with-example.aspx

strictmath

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

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

相關文章

recovery編譯問題匯總

1、修改支持USB大容量存儲 (1)、首先需要查看手機lun位置 手機鏈接電腦,打開cmd命令行,依次輸入以下命令: adb shell find /sys -name "lun" 輸出以下結果: 發現手機輸出結果有兩個,需要進一步查…

言語理解每日學習及精解20110831

【例題】天氣預報一般要考慮氣溫、氣壓、溫度、風力等因素,這些都是大氣層本身變化的結果,只要掌握這些因素,通過計算機的計算就能準確地預報天氣變化的趨勢。沙塵暴作為一種特殊的天氣現象,同樣要考慮上述氣象因素。據氣象學家分…

【數據結構基礎筆記】【棧】

代碼參考《妙趣橫生的算法.C語言實現》 文章目錄前言1、棧的定義2、創建一個棧3、入棧和出棧操作4、棧的清空、銷毀、計算棧的當前容量5、實例分析前言 本章總結:棧的定義、創建棧,銷毀棧,入棧出棧操作等操作。 1、棧的定義 棧是一種重要的…

四、正則表達式

一、正則表達式的概念和作用 正則表達式概念:一種字符串匹配的模式 正則表達式作用: 可以檢查一個字符串中是否包含某種字串替換匹配的字串提取某個字符串中匹配的字串 二、正則表達式中常見的語法 字符描述原樣字符匹配字符一般字符匹配自身beyondb…

用HTML語言制作list標記,html5 datalist標簽的用法是什么?這里有datalist標簽的用法實例...

本篇文章主要為大家講述了關于html5 datalist標簽的用法及html5 datalist標簽的用法實例。本文說了兩個常用的選項框的實例供大家選擇觀看,下面就讓我們一起來看這篇文章吧我們先來看看html5 datalist標簽的用法:標簽定義選項列表。請與input元素配合使用…

java treemap_Java TreeMap lastKey()方法與示例

java treemapTreeMap類lastKey()方法 (TreeMap Class lastKey() method) lastKey() method is available in java.util package. lastKey()方法在java.util包中可用。 lastKey() method is used to return the last highest key element value exists in this TreeMap. lastKey…

網上看來的

http://blog.163.com/dong_xiao_yang/blog/static/216138205201321114659430/ http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20compile%20FFmpeg%20for%20Raspberry%20Pi%20%28Raspbian%29#FFmpegwithlibaacpluslibx264andalsa-lib 編譯環境 Ubuntu 12.04 w64-mingw32下載lib…

閱讀iPhone.3D.Programming(O'Reilly.2010-05) 英文版 第一感覺

最近開始閱讀iPhone.3D.Programming(OReilly.2010-05),英文版此書,我閱讀到P21了,中間講了一個樣例,HelloArrow在這個過程中,我想簡單點,少打點字,直接拿書中配套來學習,發現一個問題…

【數據結構基礎筆記】【隊列】

代碼參考《妙趣橫生的算法.C語言實現》 文章目錄前言1、隊列定義2、創建一個隊列3、入隊列4、出隊列5、銷毀一個隊列6、循環隊列的概念7、循環隊列的實現8、實例分析前言 本章總結:鏈隊列定義,創建,出隊入隊操作,銷毀操作&#x…

html圖片自動循環輪播圖,js實現圖片無縫循環輪播

本文實例為大家分享了js實現圖片無縫循環輪播的具體代碼,供大家參考,具體內容如下代碼如下Document#container{overflow:hidden;width:400px;height:300px;margin:auto;}#front,#container{display:flex;flex-direction:row;}#container img{width:400px…

五、json模塊

一、json模塊的介紹 json模塊是Python自帶的模塊,用于json和Python數據之間的相互轉換 Json與Python數據類型的對應關系 JsonPythonobjectdictarrayliststringstrnumber(int)int,longnumber(real)floattrueTruefalseFalsenullNone [#中括號括起來的,對…

Android開發和調試必備工具-SDK Tools

原文鏈接:http://android.eoe.cn/topic/android_sdk SDK Tools是Android SDK的一個可下載部分,它包括Android SDK的開發和調試的所有工具。 如果你剛剛了解SDK,你可以從SDK starter package下載最新版本的SDK。 如果你已經在使用SDK&#xff…

strictmath_Java StrictMath ceil()方法與示例

strictmathStrictMath類ceil()方法 (StrictMath Class ceil() method) ceil() method is available in java.lang package. ceil()方法在java.lang包中可用。 ceil() method is used to return the least or smallest value of the double type value which is greater than or…

web應用之文件上傳

一、Jakart:Jakart文件上傳:(推薦使用) import java.io.File;import java.io.IOException;import java.util.List; import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletReq…

【數據結構基礎筆記】【樹】

代碼參考《妙趣橫生的算法.C語言實現》 文章目錄前言1、樹的概念2、二叉樹3、二叉樹的遍歷4、創建二叉樹5、實例分析前言 本章總結:樹的概念、二叉樹的創建、遍歷 1、樹的概念 樹結構是以分支關系定義得一種層次結構。 樹的定義:樹是由n(n>0)個結點…

可以自動撐起的html樣式,好好玩:CSS3抖動樣式CSS Shake讓你的網頁酷炫起來

之前在一些網站發現了一個好玩的樣式,就是鼠標移到網站LOGO上,logo會自動抖動起來,顯得非常炫酷。我也是十分感興趣。自從本站新添加了一個視覺設計的分類之后,我也是想起來有個抖動CSS樣式CSS Shake,所以今天給小伙伴…

linux技巧----查找某個正在執行的腳本

如果在機器上發現有執行的腳本,卻不知道在哪,可以這樣找 例如 # netstat -ltnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp …

成功溝通的六要素

溝通在我們的生活、工作中必不可少,成功的溝通有助于事業成功,家庭美滿!下面分享一篇關于溝通的文章,成功溝通六要素: 當蜘蛛網連接起來,可以捆住一頭獅子。——埃塞俄比亞諺語 與他人合作使我們可以實現比…

java中intvalue_Java Number intValue()方法與示例

java中intvalueNumber類intValue()方法 (Number Class intValue() method) intValue() method is available in java.lang package. intValue()方法在java.lang包中可用。 intValue() method is used to return the value denoted by this Number object converted to type int…

爬蟲項目(一)---采集最近一日世界各國的疫情數據信息

該內容出自黑馬程序員教程 采集最近一日世界各國疫情數據 步驟: 發送請求,獲取疫情首頁從疫情首頁中提取最近一日各國疫情字符串從最近一日各國疫情字符串中提取json格式字符串把json格式字符串轉換為Python類型把Python類型的數據,以json…