Java double vs BigDecimal for latitude/longitude

DD. picture DD. · Jul 20, 2011 · Viewed 40.4k times · Source

When storing latitudes/longitudes which are typically of the format: 44.087585 (i.e. max 2 numbers before the dot and 6dp) do I need to bother with bigdecimals?

Answer

TreyA picture TreyA · Jul 20, 2011

Using double has enough precision for accurate lat/lon down to inches for 6-7 decimal places. In aviation, if decimal degrees are used, they typically go to at least 7 decimal places. In our NASA simulations, lat/lon data are doubles while all other attitude and altitude are floats. In other words, the 6th decimal place for altitude isn't significant while the 6th decimal place for lat/lon is for sub-foot accuracy. You should not use float for lat/lon if you need precision down to sub-feet.

You can play around in Google Earth to see what accuracy you get by placing markers and manipulating the last decimal digit.