wuyongxiu / wuyongxiu.github.io

随便记录一下......
http://wuyongxiu.github.io
6 stars 3 forks source link

go语言的除法 #27

Open wuyongxiu opened 7 years ago

wuyongxiu commented 7 years ago

go语言的数学操作定义
Arithmetic operators apply to numeric values and yield a result of the same type as the first operand.

所以在go语言里
3/10=0 (3和10是int型)
3.0/10.0=0.3 (3.0和10.0是浮点型)
float64(3)/float64(10)=0.3

参考: http://stackoverflow.com/questions/32815400/how-to-perform-division-in-golang