samedi 1 octobre 2016

Java float comparison is not working even with Float.compare

I have _allowedPercentageDiscount = 0.0 and perentageDiscount = 1.0, First I tried with

if(_allowedPercentageDiscount < percentageDiscount)
//do something

but it never result true. Then, after some search, I tried with Float.compare but it still did not result true. Magically it gives correct result in evaluation window. (Android Studio).

enter image description here

What the hell is wrong and what to do?

Aucun commentaire:

Enregistrer un commentaire