因為兩個int類型的數(shù)據(jù)相加結(jié)果還是int類型,2/3是0.666666是浮點數(shù),自動換算成整數(shù)時舍棄后面的小數(shù),直接等于0
2018-05-07
位運算內(nèi)容很多的,位運算可以判斷奇偶,數(shù)值交換等
package main
func main() {
var a, b = 611, 193
//A = 110
a = a ^ b
b = a ^ b
a = a ^ b
println(a, b)
}
package main
func main() {
var a, b = 611, 193
//A = 110
a = a ^ b
b = a ^ b
a = a ^ b
println(a, b)
}
2018-04-29
iota前面的常量必須先賦值,如下面是錯誤的:
package main
import (
"fmt"
)
const (
a
b = iota
c
)
func main() {
fmt.Println(a, b, c)
}
package main
import (
"fmt"
)
const (
a
b = iota
c
)
func main() {
fmt.Println(a, b, c)
}
2018-04-29