The expression uint32(ci)
is a constant expression. The spec says this about constant expressions:
The values of typed constants must always be accurately representable as values of the constant type.
A uint32
cannot accurately represent the negative value ci
, therefore this expression results in a compilation error.
Positive values in range are supported. For example, uint32(-ci)
compiles with no error.
The expressions uint32(vi)
and uint32(vc)
are conversions. Conversions betweeen numeric types are allowed, even when there's loss of accuracy.