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 ...
Get Java Garage 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.