Bug #10633 Precision math: round(x,d) causes truncation if d > 30
Submitted: 13 May 2005 20:03 Modified: 9 Nov 2008 14:32
Reporter: Peter Gulutzan Email Updates:
Status: Patch pending Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.0.6-beta-debug OS:Linux (SUSE 9.2)
Assigned to: Assigned Account CPU Architecture:Any
Triage: Triaged: D2 (Serious)

[13 May 2005 20:03] Peter Gulutzan
Description:
The manual says:
"ROUND(X) , ROUND(X,D) 
Returns the argument X, rounded to the nearest integer. With two arguments, returns X rounded to D decimals."
But if D>30, MySQL rounds as if D=30.
So if I have 35  post-decimal digits and I use ROUND(X,35),
the result has 30 post-decimal digits.

How to repeat:
mysql> select round(.12345678901234567890123456789012345,35);
+------------------------------------------------+
| round(.12345678901234567890123456789012345,35) |
+------------------------------------------------+
| 0.123456789012345678901234567890               |
+------------------------------------------------+
1 row in set (0.00 sec)
[13 May 2005 20:10] Miguel Solorzano
Thank you for the bug report.
[15 Jun 2005 10:00] Alexey Botchkov
Presently we can't support more than 30 digits after the decimal point.
Should be fixed in 5.1.
[29 Sep 2008 21:53] Konstantin Osipov
No reason to keep this not fixed. We should either return an error that 35 digits are not supported, or round correctly.
[9 Nov 2008 14:32] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/58284

2709 Alexey Botchkov	2008-11-09
      Bug#10633 Precision math: round(x,d) causes truncation if d > 30 
              result of the 'DECIMAL' operation was limited with MAX_SCALE.
              But the MAX_SCAL only limits fields of tables, not the 'decimal' engine itself.
              So the limit was changed to MAX_PRECISION.
      
      per-file comments:
        mysql-test/r/func_math.result
      Bug#10633 Precision math: round(x,d) causes truncation if d > 30 
         test result fixed
        mysql-test/r/type_decimal.result
      Bug#10633 Precision math: round(x,d) causes truncation if d > 30 
         test result fixed
        mysql-test/r/type_newdecimal.result
      Bug#10633 Precision math: round(x,d) causes truncation if d > 30 
         test result fixed
        sql/item_func.cc
      Bug#10633 Precision math: round(x,d) causes truncation if d > 30 
         scale limit for decimal operation changed with MAX_PRECISION
[13 Nov 2017 0:41] Federico Razzoli
Still in 8.0.3.