In C, for comparing doubles we do: bool AreSame(double a, double b) { return std::fabs(a — b) < std::numeric_limits::epsilon(); }
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.