go语言学习-复数

来源:互联网 发布:淘宝hd登录失败 编辑:程序博客网 时间:2024/06/05 11:22
package mainimport ("reflect")import ("fmt")func main() {//复数var a1 complex64 = complex(1.1, 2.2)var a2 complex128 = complex(2.3, 3.2)fmt.Println("a1=", a1, "type=", reflect.TypeOf(a1).Name())fmt.Println("a2=", a2, "type=", reflect.TypeOf(a2).Name())fmt.Println("a2*3=", a2*3, "type=", reflect.TypeOf(a2).Name())fmt.Println("a1*a2=", complex128(a1)*a2)} 
复数是以浮点数存储
同类型的复数可以相乘
原创粉丝点击