Search
 
SCRIPT & CODE EXAMPLE
 

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
}
Comment

PREVIOUS NEXT
Code Example
Java :: java stream add to existing list 
Java :: refreshing method() android studio webview 
Java :: Valid regex check java 
Java :: while loops java 
Java :: Java 2-dimensional Array 
Java :: java double 
Java :: java assert 
Java :: java questions 
Java :: java.lang.classcastexception: java.lang.string cannot be cast to java.util.arraylist 
Java :: fragment call activity 
Java :: java dictionary initialization 
Java :: convert alphabet to number in java 
Java :: getter in java 
Java :: final variable java 
Java :: for() in java 
Java :: java creating an object 
Java :: get string size 
Java :: Implementing the LinkedList Class in java list 
Java :: java sort reverse lambda 
Java :: java.sql.SQLSyntaxErrorException: Unknown column 
Java :: java enum in switch statement 
Java :: valid parentheses leetcode solution java 
Java :: java programming problems 
Java :: Send HTTP Get Request with Parameters. 
Java :: Print the string after the specified character java 
Java :: multiple inputs java 
Java :: show menuitem when menu hovered javafx 
Java :: location.href webview android studio 
Java :: Transversal operation in java array 
Java :: What is the use of @Listener annotation in TestNG? 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =