Re: [go-nuts] int64(math.Inf(+1)) != math.MaxInt64

2022-10-03 Thread Jan Mercl
On Tue, Oct 4, 2022 at 4:18 AM Jonathan Pearson wrote: > I expected int64(math.Inf(+1)) == math.MaxInt64, but it does not. Quoting from https://go.dev/ref/spec#Conversions, section "Conversions between numeric types" In all non-constant conversions involving floating-point or complex

Re: [go-nuts] int64(math.Inf(+1)) != math.MaxInt64

2022-10-03 Thread Rob Pike
Looks like a bug to me, so I filed https://github.com/golang/go/issues/56023 Thanks for reporting it. -rob On Tue, Oct 4, 2022 at 1:18 PM Jonathan Pearson wrote: > I expected int64(math.Inf(+1)) == math.MaxInt64, but it does not. > > In fact, these three values are equal: >

[go-nuts] int64(math.Inf(+1)) != math.MaxInt64

2022-10-03 Thread Jonathan Pearson
I expected int64(math.Inf(+1)) == math.MaxInt64, but it does not. In fact, these three values are equal: int64(math.Inf(+1)) int64(math.Inf(-1)) math.MinInt64 This surprised me, and the language spec didn't clarify this specific behavior, so I wondered whether it was intentional. If so, why?