| 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.

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.