Open momchil-velikov opened 8 years ago
Personally I think the spec should be modified so that the next line permits integer constants as well as floating-point constants to be rounded.
Agreeing with @ianlancetaylor. This is a grey area that should be spec-ed out more precisely. (Some) rounding is acceptable when converting to floats.
... or perhaps the spec is does not convey the intention.
The spec says (https://golang.org/ref/spec#Conversions)
The Go compiler allows conversion in certain cases, where an integer constant value is not representable as a value of type
float32
as in:I suppose there are similar cases when converting an integer constant into
float64
,complex64
, orcomplex128
type.