Java Math hypot() Method

Facebooktwitterredditpinterestlinkedinmailby feather

The hypot() method of Math class returns the square root for the expression x2 + y2 without the intermediate underflow or overflow .

Syntax:

public static double hypot(double x, double y)

Parameters:

The parameters ‘x’ and ‘y’ represent the values.

Return Value:

The hypot () method returns the square root for the expression x2 + y2.

Special cases of the hypot() method are as follows:

  • It returns positive infinity, if either argument is infinite.
  • It returns NaN , if either argument is NaN and neither argument is infinite.

Example 1:

Output:

Example 2:

Output:

Example 3:

Output:

Example 4:

Output:

Example 5:

Output:

Facebooktwitterredditpinterestlinkedinmailby feather