Completion requirements
This chapter discusses eight primitive data types in Java.
10. Scientific Notation
Answer:
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.
Common Practice: To avoid errors, always put digits on either side of the decimal point (in programs and in writing.) So
0.1 not .1
12.0 not 12.
8912.0D not 8912D
Scientific Notation
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 to say this is that the integer that follows "E" says in which direction and for how many places to shift the decimal point. Positive integers mean right shifts; negative integers mean left shifts.
Question 10:
What is the usual way to write this number: 1.9345E+03