GO语言"math"包中"Sqrt"函数的用法及代码示例。
用法:
func Sqrt(x float64) float64
Sqrt 返回 x 的平方根。
特殊情况是:
Sqrt(+Inf) = +Inf Sqrt(±0) = ±0 Sqrt(x < 0) = NaN Sqrt(NaN) = NaN
例子:
package main
import (
"fmt"
"math"
)
func main() {
const (
a = 3
b = 4
)
c := math.Sqrt(a*a + b*b)
fmt.Printf("%.1f", c)
}
输出:
5.0
相关用法
- GO Scanner.Scan用法及代码示例
- GO StreamWriter用法及代码示例
- GO Split用法及代码示例
- GO Server.Shutdown用法及代码示例
- GO Slice用法及代码示例
- GO StructTag.Lookup用法及代码示例
- GO SplitAfter用法及代码示例
- GO Sum256用法及代码示例
- GO SectionReader用法及代码示例
- GO Sin用法及代码示例
- GO Sprintf用法及代码示例
- GO Strings用法及代码示例
- GO SendMail用法及代码示例
- GO StructTag用法及代码示例
- GO Stmt用法及代码示例
- GO Sprint用法及代码示例
- GO SpecialCase用法及代码示例
- GO SectionReader.ReadAt用法及代码示例
- GO StructOf用法及代码示例
- GO Sscanf用法及代码示例
注:本文由纯净天空筛选整理自golang.google.cn大神的英文原创作品 Sqrt。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。