created: 02/15/98; revised: 07/31/99, 01/18/00, 06/01/00, 05/11/03, 01/13/06
CHAPTER 11 — Floating Point
The Java primitive types include the
floating point types float and double.
Floating point numbers are those that include a fractional part.
When written for human viewing, a floating point number includes a decimal point.
For example, 3.14159 and -0.718802.
Chapter Topics:
- Converting strings to double
- Keyboard input of floating point numbers
- The Math class
- Square root
- Trig functions
- PI
- Not a Number (NaN)
All of the familiar mathematical functions such as
sine, log, and square root
are available to your program in the Java Math class.
These functions typically expect data type double.
QUESTION 1:
Which uses more bits: a Java float or a a Java double ?