| Author |
mysql :: I loose decimal places when i insert.
|
jite eghagha
Ranch Hand
Joined: Oct 06, 2006
Posts: 124
|
|
When i execute this sql:
my table only stores 3 decimal places :: 12.333, 12.444:
my table was created like so
I'd like to know why this happens, and how to fix it.
|
 |
ujjwal soni
Ranch Hand
Joined: Mar 28, 2007
Posts: 391
|
|
Hi,
Try using a column of type FLOAT rather than DOUBLE.
Recreate your table like the one specified as under ::::
|
Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
|
 |
jite eghagha
Ranch Hand
Joined: Oct 06, 2006
Posts: 124
|
|
I get the same result, float or double.
lat:lng
4.7064595222473145:7.076568603515625
becomes
lat:lng
4.705:7.076
|
 |
ujjwal soni
Ranch Hand
Joined: Mar 28, 2007
Posts: 391
|
|
MySQL docs mention "MySQL performs rounding when storing values" and I suspect this is the issue here. I duplicated your issue but changed the storage type to be FLOAT:
CREATE TABLE test (val, FLOAT);and the retrieved value did not matched the test value you provided.
My suggestion, for what it's worth, is use DECIMAL. I tried the same original test with:
CREATE TABLE test (val, DECIMAL(17,15));and it retrieved the value I gave it: 4.7064595222473145
Also, can you tell the version of mysql you are using ?
|
 |
jite eghagha
Ranch Hand
Joined: Oct 06, 2006
Posts: 124
|
|
|
thank you, decimal works fine.
|
 |
ujjwal soni
Ranch Hand
Joined: Mar 28, 2007
Posts: 391
|
|
Cool
|
 |
 |
|
|
subject: mysql :: I loose decimal places when i insert.
|
|
|