[MDEV-12197] Weird floating point arithmetics issue Created: 2017-03-07 Updated: 2022-12-12 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Data types |
| Affects Version/s: | 5.5, 10.0, 10.1, 10.1.21, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10 |
| Fix Version/s: | 10.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Jan Kunzmann (Inactive) | Assignee: | Alexander Barkov |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
MariaDB binary from Alpine Linux 3.5, running in a docker container on an Intel Xeon CPU (E5-2640 stepping 7, 2.50GHz) |
||
| Description |
|
H know that floating point maths isn't precise, but this particular query on a regular FLOAT field in an InnoDB table can't be explained with precision errors:
|
| Comments |
| Comment by Elena Stepanova [ 2017-03-09 ] | |||||||||||||||||
|
Please paste the output of SHOW CREATE TABLE `table`. | |||||||||||||||||
| Comment by Jan Kunzmann (Inactive) [ 2017-03-09 ] | |||||||||||||||||
|
With all the uninvolved columns removed, the create table would simply look like this:
| |||||||||||||||||
| Comment by Elena Stepanova [ 2017-03-12 ] | |||||||||||||||||
|
Thank you. Reproducible easily, not sure what went wrong on my first attempt that made me to request the table structure.
Same on MariaDB 5.5-10.2, MySQL 5.7. | |||||||||||||||||
| Comment by Alexander Barkov [ 2022-04-04 ] | |||||||||||||||||
|
Looks like a bug. The precision loss happens in Field_float::val_str() during float-to-string conversion. Note, `total + 0` returns a correct result:
Other observations:
|