mercredi 25 février 2015

Android: Compare two values doesn't work

at the moment i have a wierd problem... i can't make out where i did a mistake.


I have two pairs of values of the same type and i want to know if these are equal. When i print the values in my Log the values are equal but my if statement doesn't work :/


The values are from type double, but i reduced the decimal to two digits with BigDecimal, like this...



double a = 50.7739202f;
BigDecimal bdA = new BigDecimal(a);
BigDecimal A = bdA.setScale(2, BigDecimal.ROUND_DOWN);


A and B are 50.77 C and D are 60.07


But he always goes to else



if(A == B && C == D){
...
}
else{
...
}

Aucun commentaire:

Enregistrer un commentaire