Sample Header Ad - 728x90

Crazy automatic float rounding in MySQL 5.7

2 votes
2 answers
2805 views
My exact MySQL version is 5.7.29-0ubuntu0.18.04.1. And I'm beginning to think that I'm getting crazy... Just try these queries:
CREATE TABLE float_bug (
  v FLOAT NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=utf8;
INSERT INTO float_bug VALUES(92160596);
SELECT * FROM float_bug;
Returns 92160600. Then I tried these:
SELECT * FROM float_bug WHERE v = 92160596;
SELECT * FROM float_bug WHERE v BETWEEN 92160596 AND 92160600;
Both return nothing! However this
SELECT * FROM float_bug WHERE v = 92160592;
Returns 92160600. I'm ready to throw my computer into the wall, but unfortunately that won't help because I have exactly the same behaviour on my remote server and I can't throw it into the wall physically. Any ideas what is going on here?
Asked by Stalinko (201 rep)
Mar 11, 2020, 07:57 AM
Last activity: Mar 11, 2020, 10:58 AM