From: Panayotis K. <pan...@pa...> - 2010-11-08 16:38:20
|
On Nov 8, 2010, at 6:11 PM, Paul Poley wrote: > Checking equality on double or float values is always fishy. Unfortunately BigDecimal hasn't yet become a priority, but that would be a much safer implementation. It doesn't lose precision, making it a good candidate for sensitive numbers, such as currency calculations. > > If you do go down that route though, make sure to use "compareTo" and not "equals". E.g. "5.40" does not "equals" "5.4", but "compareTo" will return 0. Forgive me if I am stating anything you already know. > > Paul Poley The problem unfortunately is under Obj-C code and not Java. :) I agree with you, but right now, after doing some tests, I have the feeling that actually these values are used by iOS SDK more as a reference (and is checked for being larger/smaller than the specified value) and not really for equality. Thus I believe that it will be safe to use double values, for now. |