Section 3.5 Account Class with a Balance; Floating-Point Numbers and Type double
• A floating-point number (p. 84) is a number with a decimal point. Java provides two primitive types for storing floating-point numbers in memory—float
and double
(p. 84).
• Variables of type float
represent single-precision floating-point numbers and have seven significant digits. Variables of type double
represent double-precision floating-point numbers. These require twice as much memory as float
variables and provide 15 significant digits—approximately double the precision of float
variables.
• Floating-point literals (p. 84) are of type double
by default.
• Scanner
method nextDouble
(p. 88) returns a double
value.
• The format specifier %f
(p. 88) is used ...
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.