日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

strictmath_Java StrictMath hypot()方法与示例

發(fā)布時間:2025/3/11 java 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 strictmath_Java StrictMath hypot()方法与示例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

strictmath

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

  • hypot() method is available in java.lang package.

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

  • hypot() method is used to return the square root of sqrt(sq(d1)+sq(d2)) without any intermediate operations or in other words it returns the sqrt(sq(d1)+sq(d2)).

    hypot()方法用于返回sqrt(sq(d1)+ sq(d2))的平方根,而無需進行任何中間操作,換句話說,它返回sqrt(sq(d1)+ sq(d2))。

  • hypot() 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 an error.

    hypot()方法是靜態(tài)方法,因此可以使用類名進行訪問,如果嘗試使用類對象訪問該方法,則不會收到錯誤。

  • hypot() method does not throw any exception.

    hypot()方法不會引發(fā)任何異常。

Syntax:

句法:

public static double hypot(double d1 , double d2);

Parameter(s):

參數(shù):

  • double d1 , double d2 – represent the values which are being used to calculate hypot.

    double d1和double d2 –表示用于計算hypot的值。

Return value:

返回值:

The return type of this method is double – it returns the square root of the given argument.

該方法的返回類型為double-返回給定參數(shù)的平方根。

Note:

注意:

  • If we pass infinity in any of the arguments, method returns the positive infinity.

    如果我們在任何參數(shù)中傳遞無窮大,則method返回正無窮大。

  • If we pass NaN in any of the arguments, method returns NaN.

    如果我們在任何參數(shù)中傳遞NaN,則方法返回NaN。

Example:

例:

// Java program to demonstrate the example // of hypot(double d1 , double d2) method of // StrictMath class.public class Hypot {public static void main(String[] args) {// variable declarationsdouble d1 = 7.0 / 0.0;double d2 = 5.0;double d3 = 10.0;// Display previous value of d1,d2 and d3 System.out.println("d1: " + d1);System.out.println("d2: " + d2);System.out.println("d3: " + d3);// Here , we will get (Infinity) because we are // passing parameter whose value is (d2,d1)System.out.println("StrictMath.hypot(d2,d1): " + StrictMath.hypot(d2, d1));// Here , we will get (sqrt(sq(d2)+sq(d3))) because we are // passing parameter whose value is (d2,d3)System.out.println("StrictMath.hypot(d2,d3): " + StrictMath.hypot(d2, d3));} }

Output

輸出量

d1: Infinity d2: 5.0 d3: 10.0 StrictMath.hypot(d2,d1): Infinity StrictMath.hypot(d2,d3): 11.180339887498949

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

strictmath

總結

以上是生活随笔為你收集整理的strictmath_Java StrictMath hypot()方法与示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。