I need to compare extremely small numbers for an artificial intelligence project. Here is my method:
private static int maximum(BigDecimal a1, BigDecimal a2){
System.out.println(a1);
System.out.println(a2);
if (a1.compareTo(a2)<0){
return 1;
}else{
return 0;
}
Here is my output with the return value printed 3rd:
0E-917
0E-912
0
0E-918
0E-921
0
0E-932
0E-933
0
Is there any way to compare numbers this small or some simple mistake I'm making with the compareTo method? Thanks for the help!