bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math hypot() Method

❮ Math Methods

Example

System.out.println(Math.hypot(3, 4));
System.out.println(Math.hypot(1, 1));
System.out.println(Math.hypot(1, 10));

Definition and Usage

The hypot() method returns the length of the hypotenuse of a right angle triangle, which is equivalent to the distance between a 2D point (x, y) and the origin (0, 0).

This method returns a value equal to Math.sqrt(x * x + y * y) but it is optimized to prevent overflows and underflows caused during intermediate operations such as addition and multiplication.

Syntax

public static double hypot(double
x , double
y )

Parameter Values

ParameterDescription
xRequired. The x coordinate of a point.
yRequired. The y coordinate of a point.

Technical Details

Returns:A double value representing the distance between a point (x, y) and the origin (0, 0).
Java version:1.5+

Previous

Java Math getExponent() Method

Next

Java Math IEEEremainder() Method