From: Paul P. <bay...@gm...> - 2010-11-08 16:12:06
|
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 On Mon, Nov 8, 2010 at 4:13 AM, Panayotis Katsaloulis < pan...@pa...> wrote: > Hello all! > > I am implementing CoreLocation library (actually it is ready and working) > but I'd like your opinion about one thing. > > Here > > http://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html#//apple_ref/doc/uid/TP40007126-CH3-SW27 > > is a list of constant double values. These values define the accuracy of > the location, and I found that they have meaningful values (i.e > kCLLocationAccuracyNearestTenMeters is 10, kCLLocationAccuracyKilometer is > 1000 etc). > > I have created a class containing these static values, but since these are > double values and not integers, it is always possible that equality might > not work as expected. > > I tried to check every one of them with something like > java_value == kCLLocationAccuracy_value > and they all seem OK. > > > > > On the other hand, it might be possible to create a wrapper method that > returns this value, i.e. something like > > public static double Kilometer () { .. } > > in java and > > + (double) Kilometer__ { return kCLLocationAccuracyKilometer; } > > in obj-c, and use the static methods instead. > This might be safer but it is slower. > > Since the "constant variable" solution works fine, I'd rather prefer that > solution. > What do you think? > > > > ------------------------------------------------------------------------------ > The Next 800 Companies to Lead America's Growth: New Video Whitepaper > David G. Thomson, author of the best-selling book "Blueprint to a > Billion" shares his insights and actions to help propel your > business during the next growth cycle. Listen Now! > http://p.sf.net/sfu/SAP-dev2dev > _______________________________________________ > xmlvm-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-users > |