According to basic geometry, hypotenuse is nothing but the longest side of a right-angled triangle. It is the side which is opposite to the right angle of the triangle. To find the length of the hypotenuse of a right-angled triangle, the Pythagorean theorem is applied. According to this theorem, given two perpendicular sides of a triangle of length p and b, the hypotenuse can be found by the formula .
The Java.lang.StrictMath.hypot() is an inbuilt method of StrictMath class which is used to get the hypotenuse or the square-root of summation of the square of given two sides or arguments i.e. . The method excludes all the intermediate overflow and underflow. It gives rise to few special results:
- The method returns positive infinity when either of num1 or num2 is infinite.
- It returns NAN when either any argument is NAN and neither argument is infinite.
public static double hypot(double num1, double num2)
Parameters: The method accepts two parameters of Double type:
- num1: This is the first value or any one side.
- num2: This is the second value or the other side.
Return Value: The method returns i.e. length of hypotenuse.
Input: num1 = 3 num2 = 4 Output: 5.0
Below programs illustrate the Java.lang.StrictMath.hypot() Method:
Length of hypotenuse of side 11.0 & 13.8 = 17.647662734764623
Length of hypotenuse of side -54.0 & -24.8 = 59.422554640473
Hypotenuse length = NaN Hypotenuse length = Infinity
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- Java Math hypot() method with Example
- Java.lang.StrictMath class in Java | Set 1
- Java.lang.StrictMath class in Java | Set 2
- StrictMath log1p() Method in Java
- StrictMath IEEEremainder() Method in Java
- StrictMath nextAfter() Method in Java
- StrictMath tan() Method in Java
- StrictMath atan2() Method in Java
- StrictMath acos() Method in Java
- StrictMath asin() Method in Java With Examples
- StrictMath atan() Method in Java
- StrictMath cbrt() Method in Java
- StrictMath ceil() Method in Java with Examples
- StrictMath cos() Method in Java with Examples
- StrictMath exp() Method in Java
- StrictMath cosh() Method in Java
- StrictMath expm1() Method in Java With Examples
- StrictMath floor() Method in Java
- StrictMath getExponent() Method In Java
- StrictMath log() Method In Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Shivam_k