go_內建變量類型
阿新 • • 發佈:2018-03-10
com int32 cmp oat str div 不能 strong ()
bool, string
(u)int, (u)int8, (u)int16, (u)int32, (u)int64, uintptr (uintptr 是指針)
byte, rune(表示字符char)
float32, float64, complex64, complex128 (complex表示復數)
go語言只能強制類型轉換,不能隱式轉化
package main import ( "fmt" "math/cmplx" "math" ) func elert(){ c:=3+4i fmt.Println(cmplx.Abs(c)) //歐拉公式 //fmt.Println( // cmplx.Exp(1i*math.Pi)+1 //) } //go語言只能強制類型轉換,不能隱式轉化 func triangle(){ var a,b int =3,4 var c int c = int(math.Sqrt(float64(a * a + b * b))) fmt.Println(c) } func main() { elert() triangle() }
go_內建變量類型