Re: [go-nuts] Why float64 variable with value 0.0 as divisor produce +Inf?

2017-05-08 Thread Van Hu
or of a constant division or remainder operation must not be zero: 3.14 / 0.0 // illegal: division by zero On Tuesday, May 9, 2017 at 9:48:53 AM UTC+8, Michael Jones wrote: > > This is the definition of that division. > > What result would you prefer? > > On Mon, May 8, 2017 at

[go-nuts] Why float64 variable with value 0.0 as divisor produce +Inf?

2017-05-08 Thread Van Hu
Hi, my colleague found this strange behavior in Go today, seems like a bug? package main import ( "fmt" ) func main() { var a float64 = 0.0 fmt.Println(1.0 / a) // prints +Inf } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe f

[go-nuts] Re: Help me, i don't understand why

2016-09-05 Thread Van Hu
Hope this helps: https://play.golang.org/p/5UnIuSE50F package main import "time" func main() { // redact ch1 := make(chan struct{}) ch2 := make(chan struct{}) go func() { for _, value := range []int{1, 3, 5} { // redact println(value) // redact <-ch1 ch2<-struct{}{} } }() go func() { for _, val