int s = 1e9;
What is type of 1e9
and how precise is it? (Is it exactly equal to 1000000000?)
Printing type of a value/variable to stdout
would be useful if it's possible.
1e9
is a double
that has an exact representation in the IEEE floating point representation. The C++ standard doesn't mandate IEEE floating point.
s
is an int
, so the double
value will be automatically converted to an int
. How this takes place is to some extent up to the implementation. On most machines nowadays, this conversion means s
will be given an initial value of 1000000000.