static double hypot(double x, double y)
描述 (Description)
java.lang.Math.hypot(double x, double y)返回sqrt(x 2 + y 2 )而没有中间溢出或下溢。 特别案例:如果任一参数是无穷大,则结果为正无穷大。
如果任一参数是NaN且两个参数都不是无穷大,则结果为NaN。
声明 (Declaration)
以下是java.lang.Math.hypot()方法的声明public static double hypot(double x, double y)
参数 (Parameters)x - 一个值
y - 一个值
返回值 (Return Value)
此方法返回sqrt(x 2 + y 2 )而没有中间溢出或下溢
异常 (Exception)
NA
例子 (Example)
以下示例显示了lang.Math.hypot()方法的用法。package com.iowiki;
import java.lang.*;
public class MathDemo {
public static void main(String[] args) {
// get two double numbers
double x = 60984.1;
double y = -497.99;
// call hypot and print the result
System.out.println("Math.hypot(" + x + "," + y + ")=" + Math.hypot(x, y));
}
}
让我们编译并运行上面的程序,这将产生以下结果 -Math.hypot(60984.1, -497.99)=60986.133234122164