Bug #43262 Float values lose precision when dumped out and reloaded

Submitted: 27 Feb 2009 13:26 Modified: 27 Feb 2009 15:50
Reporter: Balint Toth Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Data Types Severity:S3 (Non-critical)
Version: 5.0.30, 5.1.31 OS:Linux
Assigned to: CPU Architecture:Any
Tags: float dump

[27 Feb 2009 13:26] Balint Toth
Description:
When you dump a table with float values precision is lost.

Also when you just select the previously inserted row, it's rounded.

How to repeat:
CREATE TABLE `ftest` (
  `f` float default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

insert into ftest values (10000.78);

mysql> select * from ftest;
+---------+
| f       |
+---------+
| 10000.8 | 
+---------+

mysql> select f*100 from ftest;
+-----------------+
| f*100           |
+-----------------+
| 1000078.0273438 | 
+-----------------+

mysqldump output:
INSERT INTO `ftest` VALUES (10000.8);

When you convert the field to a decimal type, the decimals appear:

mysql> alter table ftest modify f decimal(12,4);
Query OK, 1 row affected, 1 warning (0.03 sec)
Records: 1  Duplicates: 0  Warnings: 1

mysql> select * From ftest;
+------------+
| f          |
+------------+
| 10000.7803 | 
+------------+
1 row in set (0.00 sec)
[27 Feb 2009 15:50] Valeriy Kravchuk
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/refman/5.1/en/problems-with-float.html and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.