/**************************************************************************** * Name: RoundoffError * Author: Lara Wear * Date: Dec 15, 2004 * Purpose: To display the round-off effects of floating point arithmetic *****************************************************************************/ public class RoundoffError { public static void main(String[] args) { // method variables double x; double y; double z; x = 1000 / 3.0; System.out.println("1000 / 3.0 = " + x); y = x - 333.0; System.out.println("x - 333.0 = " + y); z = 3 * y - 1.0; System.out.println("3*y - 1.0 = " + z); if (z == 0) { System.out.println("z is zero"); } // if else { System.out.println("z is not zero"); } // else } //main } //RoundoffError