CHAPTER 11 — Floating Point

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to home page   hear noise   go to next page

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 ?