tags:

views:

126

answers:

2

I am trying to store latitude 39.8162994 and longitude -98.5576019 as floats but turns out be like 0.00000000000 and -98.55760192871, accordingly.

What's the problem? I am using float(15,11) as a data type.

+5  A: 

You should probably use DECIMAL(10,7) in order to be able to store a longitude value with 7 decimal places: ±179.1234567. The FLOAT data type is used to represent approximate numeric data values, where on the other hand you might prefer to store the exact values with the DECIMAL data type instead.

Daniel Vassallo
+3  A: 

I would recommend that you either use a DECIMAL type or store it as an integer with a known offset (say 10e-7).

Use at least as many digits precision as you need to keep:

DECIMAL(15,12)
Kaleb Pederson