4

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.

2
  • 1
    Can you post the code you use to insert the data? Commented Mar 3, 2010 at 20:43
  • Hey, Mark! How would I store latitude and longitude like those I pointed with the help of php? What should I set on the table? Commented Mar 3, 2010 at 20:49

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.