Comparison

Revision en3, by rahul_1234, 2015-07-13 16:49:19

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.

Tags comparison

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English rahul_1234 2015-07-13 16:49:19 2 Tiny change: '**In C, for comp' -> '**In C++, for comp'
en2 English rahul_1234 2015-07-13 16:47:54 14
en1 English rahul_1234 2015-07-13 16:46:31 375 Initial revision (published)