WtComp.java Source code

Java tutorial

Introduction

Here is the source code for WtComp.java

Source

class WtComp {
    public static boolean equals(double v1, // First argument
            double v2, // Second argument
            double e) // Epsilon
    {
        return Math.abs(v1 - v2) < e;
    }

    public static void main(String[] args) {

        double a = 9.33333333333000;
        double b = 9.33333333333333;
        final double EPSILON = 1.0E-10;

        if (equals(a, b, EPSILON))
            System.out.println("values are equal");
        else
            System.out.println("values are not equal");
    }
}