Reputation: 17299
I want to insert the value 33.55555
to database. Even after changing mysql row to float
or decimal
, I am unable to do so correctly.
mysql:
ALTER TABLE `test` CHANGE `test1` `test1` DECIMAL( 10,10 ) NOT NULL
after inserting 33.55555
it is converted to 0.9999999999
via this sql command
ALTER TABLE `test` CHANGE `test1` `test1` FLOAT( 10,10 ) NOT NULL
33.55555
is converted to 1.0000000000
Upvotes: 2
Views: 6763
Reputation: 1755
Your DECIMAL() and FLOAT() declarations are off. The first parameter is how long you want the number to be, the second parameter is how many of those are decimals. So when you say FLOAT(10,10) you are saying give me a column that is 10 digits long with 10 of those digits after the decimal point.
Decimal and Float are also different in their terms of approximation. Decimals are fixed point values while floats are floating point values.
The .999999999 and 1.000000 are the maximum values for the columns.
Try this to insert 35.55555:
ALTER TABLE `test` CHANGE `test1` `test1` DECIMAL( 7,5 ) NOT NULL
Upvotes: 5