All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.pdx.cs410J.tips.DoubleTrouble Maven / Gradle / Ivy

The newest version!
package edu.pdx.cs410J.tips;

/**
 * This program demonstrates that doubles only provide
 * approximations of negative powers of 10.
 *
 * @see BigDecimalDemo
 *
 * @author David Whitlock
 * @version $Revision: 1.1 $
 */
public class DoubleTrouble {

  public static void main(String[] args) {
    double increment = 0.10;  // Not REALLY 0.10
    double total = 0.0;
    for (int i = 0; i < 10; i++) {
      System.out.println(total);
      total += increment;
    }
    System.out.println(total + (total == 1.00 ? "\nYes" : "\nNo?"));
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy