Real Numbers
The Java floating point types are float and double. Floating point types are numbers with a decimal place.
float
Occupies 32 bits or 4 bytes, with 6 or 7 significant digits
Default value of 0.0
Range: 6-7 significant decimal digits
Example: 3.1459F
You specify the float by placing an F literal after the float value. If you don't, the compiler will treat your number as a double.
Java floating point numbers follow the IEE754 specification, which includes positive and negative signed numbers, positive and negative zero, and a special value referred to as NaN (Not a Number).
NaN is used to represent the result of an illegal or invalid operation, such as an attempt to divide by zero. The Float and Double wrapper classes both have a method ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access