In C++, for comparing doubles we do:
bool AreSame(double a, double b) { return fabs(a — b) < epsilon; } // epsilon : 0.000000001
However in java to compare Bigdecimal properly would this suffice:
if(r.compareTo(BigDecimal.ZERO) == 0) { System.out.print("Yes"); }
Or we have to do something else. Can somebody elaborate on this.