bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math hypot() Method

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java Math hypot() Method?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___.out.println(Math.hypot(3, 4));
3Order

Put the learning moves in the order that makes the concept easiest to apply.

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).
Definition and Usage
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