GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — Java Math hypot() Method - GeeksforGeeks Java Math hypot() MethodLast Updated : 7 May, 2025 The Math.hypot() function is an in-built Math function in Java. Before going deep dive to the topic, first understand the reason behind to use this function. Suppose we have a right-angled triangle and we know the lengths of the two shorter sides i.e., x and y. To calculate the hypotenuse, we use sqrt(x*x + y*y) formula. But Java has this in-built function i.e., Math.hypot() to handle very large or small values easily. This function returns the Euclidean distance of a right-angled triangle with the sides of length x and y. The method returns sqrt(x2 + y2) without intermediate overflow or underflow.
Syntax of Math hypot() Method
Examples of Java Math hypot() MethodExample 1: In this example, we will see the working of java.lang.Math.hypot() method.
Output hypot(3,4): 5.0 Explanation: The square root of (3*3 + 4*4) is 5. Example 2: In this example, we will see how to handle NaN.
Output hypot(NaN,2): NaN Explanation: Here, one argument is NaN and one is no infinite value, so the result id NaN. Example 3: In this example, we will see how to handle infinite values.
Output hypot(Inf,5): Infinity hypot(Inf, -Inf): Infinity Explanation: Here, both the arguments are infinite, so it results hypotenuse. Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |