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?
Java double vs BigDecimal for latitude/longitude
bigdecimaldoublegeospatialjavalatitude-longitude
Related Topic
- Java – Is Java “pass-by-reference” or “pass-by-value”
- Java – How to round a number to n decimal places in Java
- Java – the difference between public, protected, package-private and private in Java
- Java – Avoiding NullPointerException in Java
- Java – How to read / convert an InputStream into a String in Java
- Java – How to generate random integers within a specific range in Java
- .net – Difference between decimal, float and double in .NET
- Java – Comparing Java enum members: == or equals()
Best Answer
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 aredoubles
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 usefloat
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.