You should read this or this.
The type of the integer literal is the first type in which the value
can fit, from the list of types which depends on which numeric base
and which integer-suffix was used.
(Thanks to @UnHolySheep who makes me notice it).
If you want the compiler to interpret differently your literal, you have to add a suffix. For example, with int
, you can add LL
or ll
to specify that it's a long long int
. With unsigned numbers the suffix is u
.
With floating point literals, it's the same: there's a default type, which is double
, but if you want a float
you can easily use the f
(or f
) suffix. With floating point you can even use exponential rappresentation (usign the e
).