java.lang.StrictMath.hypot() 方法返回%uA0sqrt(x2%uA0+ y2)%uA0没有中间溢或下溢。它包括了一些情况:
- 如果任一参数为无穷大,那么结果为正无穷大。
- 如果任一参数为NaN和参数都不是无限的,那么结果为NaN。
声明
以下是java.lang.StrictMath.hypot()方法的声明
public static double hypot(double x, double y)
参数
-
x%uA0-- 这是所使用的值。
-
y%uA0-- 这是所使用的值。
返回值
此方法返回 sqrt(x2%uA0+ y2) %uA0没有中间溢或下溢。
异常
-
NA
例子
下面的例子显示java.lang.StrictMath.hypot()方法的使用。
package com.yiibai import java.lang.* public class StrictMathDemo { public static void main(String[] args) { double d1 = 3, d2 = 4, d3 = 6 // returns sqrt(x2 + y2) double hypotValue = StrictMath.hypot(d1, d2) System.out.println("hypotenuse value of d1 and d2 = " + hypotValue) hypotValue = StrictMath.hypot(d2, d3) System.out.println("hypotenuse value of d2 and d3 = " + hypotValue) } }
让我们来编译和运行上面的程序,这将产生以下结果:
hypotenuse value of d1 and d2 = 5.0 hypotenuse value of d2 and d3 = 7.211102550927978