[MCOL-249] wrong decimal sum when using FLOAT type Created: 2016-07-05 Updated: 2016-08-16 Resolved: 2016-08-16 |
|
| Status: | Closed |
| Project: | MariaDB ColumnStore |
| Component/s: | MariaDB Server |
| Affects Version/s: | 1.0.2 |
| Fix Version/s: | 1.0.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Xrizoo | Assignee: | Andrew Hutchings (Inactive) |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Environment: |
OpenSUSE 42.1 (act as a server) |
||
| Description |
|
To reproduce the error, build this table as example: {{CREATE TABLE `test` ( It only need a 1 record, but you must use any. Use this for example: {{INSERT INTO `test` (`FACTURA`, `FECHA`, `IMPORTE`) VALUES Finally, run this query: {{select factura, CONCAT_WS(',',FECHA) as FECHA, SUM(importe) AS IMPORTE The result is: As you can see = 877.7999877929688 <> 877.8 |
| Comments |
| Comment by Xrizoo [ 2016-07-05 ] |
|
Finally, i found that the problem was other. The query returns the same wrong error without the function concat_ws(). |
| Comment by Andrew Hutchings (Inactive) [ 2016-08-16 ] |
|
This isn't just a ColumnStore issue, it happens in all engines and is expected behaviour. The FLOAT and DOUBLE data types use approximate storage for the values, the same as float/double in most programming languages. There is a display precision by default when running a basic query but using 'SUM()' passes the float through a function and therefore will not use the display precision. It is recommended if you wish to use accurate floating point storage to use the DECIMAL data type. |
| Comment by Justin Swanhart (Inactive) [ 2016-08-16 ] |
|
More info can be found here: |