java.lang.Math.hypot(double x, double y)%uA0返回 sqrt(x2%uA0+y2) 没有中间溢或下溢。特殊情况:
-
如果任一参数为无穷大,那么结果为正无穷大。
-
如果任一参数为NaN和参数都不是无限的,那么结果为NaN。
声明
以下是java.lang.Math.hypot()方法的声明
public static double hypot(double x, double y)
参数
-
x%uA0-- 一个double值
-
y%uA0-- 一个double
返回值
此方法返回 sqrt(x2%uA0+y2) 没有中间溢或下溢
异常
-
NA
例子
下面的例子显示lang.Math.hypot()方法的使用。
package com.yiibai 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