go_内建变量类型

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()
}

  

原文地址:https://www.cnblogs.com/luffe/p/8538696.html