class MachineEpsilonProblem {
  public static void main(String[] args) {
    
    // remember a few weeks ago, I demonstrated that 
    // if you use math.sqrt() to calculate the root of 2, then squared it,
    // it does not equal 2.
    // How would we determine that we have arrived at a close approximation?
    // here is (approximately) the original code we looked at
    double EPSILON = 1e-6;
    double nbr2 = 2.0;
    double root2 = Math.sqrt(nbr2);
    double squaredRoot2 = root2 * root2;
    System.out.println("with no adjustment,");
    System.out.println("the square root of 2.0, squared, equals 2.0 evaluates to: " 
                         + (squaredRoot2 == nbr2));
    System.out.println("Considering the small loss, and adjusting for it,");
    boolean result = Math.abs(squaredRoot2 - nbr2) <= EPSILON;
    System.out.println("the square root of 2.0, squared, equals 2.0 evaluates to: " 
                         + result);
    
  }
}