[MDEV-5934] ROUND(double) is inconsistent about fractional digits Created: 2014-03-23  Updated: 2022-09-08

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.3.12, 5.5.36, 10.0.9
Fix Version/s: 5.5

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None


 Description   

For a double type argument,
ROUND(1e0, N) returns N fractional digits when N is <31,
and 0 fractional digits when N is >=31.

+--------------+----------------------------------+---------------+----------------+
| ROUND(1e0,5) | ROUND(1e0,30)                    | ROUND(1e0,31) | ROUND(1e0,100) |
+--------------+----------------------------------+---------------+----------------+
|      1.00000 | 1.000000000000000000000000000000 |             1 |              1 |
+--------------+----------------------------------+---------------+----------------+

For a decimal type argument ROUND(1.0,N) works differently:

+--------------+----------------------------------+----------------------------------+----------------------------------+
| ROUND(1.0,5) | ROUND(1.0,30)                    | ROUND(1.0,31)                    | ROUND(1.0,100)                   |
+--------------+----------------------------------+----------------------------------+----------------------------------+
|      1.00000 | 1.000000000000000000000000000000 | 1.000000000000000000000000000000 | 1.000000000000000000000000000000 |
+--------------+----------------------------------+----------------------------------+----------------------------------+

It returns N fractional digits for N<31, and 30 fractional digits for N>=31.

Not sure which is more correct, but it would be nice to have
similar behaviour for the two data types.


Generated at Thu Feb 08 07:08:08 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.