Bug #108374 simple float type sum calculations produce unexpected results
| Submitted: | 3 Sep 2022 6:38 | Modified: | 3 Sep 2022 7:04 |
|---|---|---|---|
| Reporter: | Eimar Koort | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: General | Severity: | S3 (Non-critical) |
| Version: | 8.0.26 | OS: | Other (Rocky 9) |
| Assigned to: | CPU Architecture: | x86 |
[3 Sep 2022 7:04]
Eimar Koort
After reading (!) documentation i'll close this bug. https://dev.mysql.com/doc/refman/8.0/en/problems-with-float.html Thanks.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.049 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.
Description: Taking sum from float type produces unexptected answers. How to repeat: mysql> create table bla(mycol float); mysql> desc bla; +-------+-------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------+------+-----+---------+-------+ | mycol | float | YES | | NULL | | +-------+-------+------+-----+---------+-------+ Insert two numbers into this table and select sum from them. Combination of '0' and '0' produces '0', '0' and '1' produces '1', '0' and '1.0' produces '1' as expected. Now it goes weird. mysql> insert into bla values ('1.01'); mysql> insert into bla values ('1'); mysql> select * from bla; +-------+ | mycol | +-------+ | 1.01 | | 1 | +-------+ mysql> select sum(mycol) from bla ; +-------------------+ | sum(mycol) | +-------------------+ | 2.009999990463257 | +-------------------+ I would expect it to return "2.01" as an answer.