Math.hypot
Math.hypot
功能
斜边长度。返回 sqrt(x x + y y) 的斜边长度。
语法
Math.hypot(x, y)
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| x | Number | 是 | 无 | 直角边 x。 |
| y | Number | 是 | 无 | 直角边 y。 |
返回值
| 类型 | 说明 |
|---|---|
| Int/Float | 返回 sqrt(x x + y y) 的斜边长度。整数结果返回 Int,非整数或非有限结果返回 Float。 |
示例
result = Math.hypot(3, 4) // 输出:5 print result
注意事项
- 内部使用 Rust f64 的 hypot 运算。