(Thought question: ) Do you think that using float
instead of double
saves a significant amount of computer
memory?
No. For most programs using variables of type double
will cost only
a few extra bytes in a program thousands of bytes long.
Sometimes you need to explicily 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 explicily ask for a double-precision 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
.
Do you think that the following is legal?
double rats = 8912D ;