Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to compare doubles in java

private static void testBdEquality() 
{
     BigDecimal a = new BigDecimal("2.00");
     BigDecimal b = new BigDecimal("2.0");
 
     System.out.println(a.equals(b));           // false
 
     System.out.println(a.compareTo(b) == 0);   // true
}
 
PREVIOUS NEXT
Tagged: #compare #doubles #java
ADD COMMENT
Topic
Name
1+9 =