Re: [go-nuts] Re: why is the "1" in the code demoed in Go spec deduced as a "float64" value instead of an "int" value?

2018-03-07 Thread Volker Dobler
On Thursday, 8 March 2018 00:02:58 UTC+1, Ian Lance Taylor wrote: > > > If we ignore the type context, then > > var v int64 = 1 << s > > fails on 32-bit systems if s > 31 (because 1 is assigned type int, > which is 32 bits, and the shifting a 32-bit value by more than 31 bits > gives you zero)

Re: [go-nuts] Re: why is the "1" in the code demoed in Go spec deduced as a "float64" value instead of an "int" value?

2018-03-07 Thread digg
On Wednesday, March 7, 2018 at 6:02:58 PM UTC-5, Ian Lance Taylor wrote: > > On Wed, Mar 7, 2018 at 1:36 PM, > > wrote: > > > > On Wednesday, March 7, 2018 at 4:26:19 PM UTC-5, di...@veryhaha.com > wrote: > >> > >> get it almost. > >> > >> But I feel > >> > >> var v = float32(1< >>

Re: [go-nuts] Re: why is the "1" in the code demoed in Go spec deduced as a "float64" value instead of an "int" value?

2018-03-07 Thread Ian Lance Taylor
On Wed, Mar 7, 2018 at 1:36 PM, wrote: > > On Wednesday, March 7, 2018 at 4:26:19 PM UTC-5, di...@veryhaha.com wrote: >> >> get it almost. >> >> But I feel >> >> var v = float32(1<> is a little different to >> var v float32 = 1<> >> >> For the former one, we think "1" can be assumed as an

Re: [go-nuts] Re: why is the "1" in the code demoed in Go spec deduced as a "float64" value instead of an "int" value?

2018-03-07 Thread Michael Jones
of course you can force it: https://play.golang.org/p/QIWDeMDJlAq On Wed, Mar 7, 2018 at 1:36 PM, wrote: > > > On Wednesday, March 7, 2018 at 4:26:19 PM UTC-5, di...@veryhaha.com wrote: >> >> get it almost. >> >> But I feel >> >> var v = float32(1<> is a little different to >> var v floa

Re: [go-nuts] Re: why is the "1" in the code demoed in Go spec deduced as a "float64" value instead of an "int" value?

2018-03-07 Thread digg
On Wednesday, March 7, 2018 at 4:26:19 PM UTC-5, di...@veryhaha.com wrote: > > get it almost. > > But I feel > > var v = float32(1< is a little different to > var v float32 = 1< > > For the former one, we think "1" can be assumed as an "int". > But anyway, I get the main point of the desi

Re: [go-nuts] Re: why is the "1" in the code demoed in Go spec deduced as a "float64" value instead of an "int" value?

2018-03-07 Thread digg
get it almost. But I feel var v = float32(1< > On Wed, Mar 7, 2018 at 12:54 PM, Volker Dobler > > wrote: > > Looks suspicious. Without crosschecking the Spec: Might be > > a bug. File an issue? > > It's not a bug. See Andrey's reply. > > Ian > > > > > On Wednesday, 7 March 2018 21:39:

Re: [go-nuts] Re: why is the "1" in the code demoed in Go spec deduced as a "float64" value instead of an "int" value?

2018-03-07 Thread Ian Lance Taylor
On Wed, Mar 7, 2018 at 12:54 PM, Volker Dobler wrote: > Looks suspicious. Without crosschecking the Spec: Might be > a bug. File an issue? It's not a bug. See Andrey's reply. Ian > On Wednesday, 7 March 2018 21:39:32 UTC+1, di...@veryhaha.com wrote: >> >> var s uint = 33 >> var u2 = float64