Float not correct in MySQL

前端 未结 5 1760
旧时难觅i
旧时难觅i 2020-12-06 14:06

I am entering \'35444650.00\' as a float into my MySQL and it keeps reformatting to 35444648.00, any help welcome...

5条回答
  •  死守一世寂寞
    2020-12-06 15:02

    The MySQL manual claims that FLOAT, REAL, and DOUBLE PRECISION fields stores values as approximate and INTEGER, SMALLINT, DECIMAL, and NUMERIC fields stores values as exact.

    I think best bet to overcome this precision issue is to use decimal.

    Reference: http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html

提交回复
热议问题