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
- Java Math hypot() method with Example
- StrictMath pow() Method in Java
- StrictMath sin() Method in Java
- StrictMath exp() Method in Java
- StrictMath tan() Method in Java
- StrictMath log() Method In Java
- StrictMath toRadians() Method in Java
- StrictMath log1p() Method in Java
- StrictMath toDegrees() Method in Java
- StrictMath atan2() Method in Java
- StrictMath ulp() Method In Java with Examples
- StrictMath fma() method in Java with Examples
- StrictMath random() Method in Java
- StrictMath nextAfter() Method in Java
- StrictMath scalb() 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