Bug #10083 round(x,y) doesn't work, when x is integer and y > 0
Submitted: 22 Apr 2005 4:47 Modified: 3 May 2007 4:10
Reporter: Ronald Weiss
Status: Closed
Category:Server Severity:S3 (Non-critical)
Version:5.0.4 OS:Microsoft Windows (winXP)
Assigned to: Alexey Botchkov Target Version:

[22 Apr 2005 4:47] Ronald Weiss
Description:
The synopsis is clear enough I think.
SELECT ROUND(150,2) returns "150".
I think it should return "150.00" shouldn't it?

I tried in on a 3.23 server, there it is ok.

How to repeat:
SELECT ROUND(150,2)
[22 Apr 2005 19:06] Jorge del Conde
Reproduced w/5.0.5 from bk.

This problem doesn't happen in 4.1
[9 Jun 2005 12:29] 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/internals/25807
[9 Jun 2005 12:30] Alexey Botchkov
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html
[1 May 2007 22:58] Bugs System
Pushed into 5.1.18-beta
[1 May 2007 22:59] Bugs System
Pushed into 5.0.42
[2 May 2007 0:58] Timothy Smith
For docs team:  I'm not sure if this requires amending the documentation; the fix for this
bug (bug #10083) was reverted as part of the fix for bug #24912.  See changeset comments
on that bug for details.

It was determined that this bug should have been classified as "Not a Bug", and that
ROUND(<integer type>, <positive value>) should still return an integer type.  See the
manual for more details on ROUND() behavior and return type.
[3 May 2007 4:10] Paul DuBois
I'll add an example to the 5.0/5.1 manuals to illustrate
what happens for integer and non-integer values.
The manual does indicate already that the return type
is the same as the argument type.

Example:

mysql> SELECT ROUND(150.000,2), ROUND(150,2);
+------------------+--------------+
| ROUND(150.000,2) | ROUND(150,2) |
+------------------+--------------+
|           150.00 |          150 |
+------------------+--------------+