Bug #8430 Precision math: CEILING returns incorrect result
Submitted: 11 Feb 2005 0:49 Modified: 4 Mar 2005 19:36
Reporter: Trudy Pelzer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.3-alpha-debug OS:Linux (SuSE 9.1)
Assigned to: Alexey Botchkov CPU Architecture:Any

[11 Feb 2005 0:49] Trudy Pelzer
Description:
According to the MySQL Reference Manual, the result
of CEILING should be the smallest integer that is not
less than the argument. This is not always the case.

How to repeat:
mysql> select ceiling(999999999999999999);
+-----------------------------+
| ceiling(999999999999999999) |
+-----------------------------+
|         1000000000000000000 |
+-----------------------------+
1 row in set (0.00 sec)
-- This is the incorrect result. The function should return
999999999999999999.

mysql> create table t (col1 int,col2 decimal(38,22);
mysql> insert into t values(4,-9.9999999999999999999999);

mysql> select ceiling(col2) from t where col1=4;
+---------------+
| ceiling(col2) |
+---------------+
|           -10 |
+---------------+
1 row in set (0.00 sec)
-- This is the incorrect result. The function should return -9.
[11 Feb 2005 1:13] MySQL Verification Team
Thank you for the bug report.

create table t (col1 int,col2 decimal(38,22);

change to:

create table t (col1 int,col2 decimal(38,22));

for to run the test case.
[4 Mar 2005 15:38] 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/22664
[4 Mar 2005 19:36] 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