Primitive types
Overview
V supports a wide range of primitive types. Below is a list of all supported primitive types:
Unlike C and Go,
int
is always a 32-bit integer.
Promotions
There is an exception to the rule that all operators in V must have values of the same type on both sides. A small primitive type on one side can be automatically promoted if it fits completely into the data range of the type on the other side.
These are the allowed possibilities:
An int
value for example can be automatically promoted to f64
or i64
but not to u32
(u32
would mean loss of the sign for
negative values).
Promotion from int
to f32
, however, is currently done automatically
(but can lead to precision loss for large values).
Literals like 123
or 4.56
are treated in a special way. They do
not lead to type promotions, however they default to int
and f64
respectively, when their type has to be decided: