This chapter discusses eight primitive data types in Java.
11. Precision of Floating Point Numbers
Answer:
1934.5
The +03 says to move the decimal point three places right.
Precision of Floating Point Numbers
Consider writing the value 1/3 in decimal notation:
0.333333333333333333
There is no limit to the number of 3's required for complete accuracy. However, with a limited amount of paper, you can not be completely accurate. With a data type, there is a limited number of bits. Those bits cannot accurately represent a value that requires more than that number of bits.
The data type float
has 24 bits of precision. This is equivalent to only about 7 decimal places. (The rest of the 32 bits are used for the sign and size of the number.)
The number of places of precision for float
is the same no matter what the size of the number. Data type float
can represent numbers as big as about 3.4E+38. But the precision of these large numbers will also be about 7 decimal digits.
Remember: data type float
has about the range and precision of a cheap pocket calculator. This is usually not sufficient.
Question 11:
What is wrong with the following constant, expected to be of type
float
?1230.00089F