Friday 1 September 2017

Java Float vs Double

Cited from the Book Java How to Program

Java provides two primitive types for storing floating-point numbers in memory—float and double. They differ primarily in that double variables can store numbers with larger magnitude and finer detail (i.e., more digits to the right of the decimal point—also known as the number’s precision) than float variables.

Variables of type float represent single-precision floating-point numbers and can represent up to seven significant digits. Variables of type double represent double-precision floatingpoint numbers. These require twice as much memory as float variables and provide 15 significant digits -- approximately double the precision of float variables.

No comments:

Post a Comment