Primitive Data
9. Floating Point Literals
Answer:
No. For most programs using variables of type double
will cost only a few extra bytes.
This is insignificant in a program thousands of bytes long.
Floating Point Literals
Sometimes you need to explicitly ask for a single-precision float
literal. Do this by putting a lower case f
or upper case F
at the end, like this:
123.0f
-123.5F
-198234.234f
0.00000381F
Sometimes you need to explicitly ask for a double
literal. Do this by putting a lower case d
or upper case D
at the end, like this:
123.0d
-123.5D
-198234.234d
0.00000381D
Remember, that without any letter at the end, a floating point literal will automatically be of type double
.
Question 9:
Do you think that the following is legal?
8912D