Do you think that the following is legal?
double rats = 8912D ;
Yes. The 'D' will make the literal a double
(even though it lacks a decimal point).
However, to avoid confusion, always include a decimal point
in a floating point literal,
even where it is not required.
Either of the following also works:
double rats = 8912 ;
or
double rats = 8912.0 ;
The first statement (above) works, but is "sloppy" coding.
The integer literal must be converted into a double before
the variable is initialized.
In the second statement the variable is initialized
to the double
literal.
You will sometimes see scientific notation. The following are all double-precision literals:
1.23E+02 -1.235E+02 -1.98234234E+05 3.81E-06
Another way of regarding the integer that follows the "E" is that it says in which direction and for how many places to shift the decimal point. Positive integers mean right shifts; negative integers mean left shifts.
What is the following number if written out the usual way: 1.9345E+03