When an untyped integer constant is converted to a typed value, it always 
becomes int. I suppose the rules could be made more complicated to handle 
values that won’t fit in an int. But what if the value is too big to fit in a 
uint64? Should it be a float64 then?

Andy

> On Dec 5, 2018, at 8:54 AM, Michel Levieux <m.levi...@capitaldata.fr> wrote:
> 
> Well the only thing I do in the main is :
> 
> fmt.Println(v)
> 
> Shouldn't the compiler statically type v to uint64?
> I don't get the need to force type of v to uint64?
> 
> Le mer. 5 déc. 2018 à 17:45, Andy Balholm <andybalh...@gmail.com 
> <mailto:andybalh...@gmail.com>> a écrit :
> Apparently in your code the value is being assigned to an int. But it’s too 
> large for an int; it needs a uint64 to hold it.
> 
> Andy
> 
>> On Dec 5, 2018, at 8:35 AM, Michel Levieux <m.levi...@capitaldata.fr 
>> <mailto:m.levi...@capitaldata.fr>> wrote:
>> 
>> Hi guys,
>> 
>> With a colleague of mine, we've run into a strange issue today. When we look 
>> at package math, in const.go, we can see this line :
>> 
>> MaxUint64 = 1<<64 - 1
>> 
>> which I assume works pretty well. But if I do the same in a test main and 
>> try to 'go run' it, with this line :
>> 
>> const v = 1 << 64 - 1
>> 
>> I get the following error :
>> 
>> ./testmain.go:8:13: constant 18446744073709551615 overflows int
>> 
>> I think this is not a bug and we're just missing something here. Could 
>> anyone explain this behaviour / point me to a documentation that explains it?
>> 
>> Thank you guys
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts+unsubscr...@googlegroups.com 
>> <mailto:golang-nuts+unsubscr...@googlegroups.com>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to