On Thu, 28 Feb 2002 15:32:24 +0100, Roger Baklund wrote:

>As far as I can tell, there are at least two bugs.
>
>One bug is already known, it is the rounding error that applies to some
>platforms, depending on the underlaying C library being used:
>
>win2k, 3.23.30-gamma:
>
>mysql> select round(1.5);
>+------------+
>| round(1.5) |
>+------------+
>|          1 |
>+------------+
>1 row in set (0.00 sec)
>
>solaris, 3.23.39-log:
>
>mysql> select round(1.5);
>+------------+
>| round(1.5) |
>+------------+
>|          2 |
>+------------+
>1 row in set (0.02 sec)
>
>This is... inconvenient. Even if the reason for the bug is the different C
>library implementations, the result will be mysql applications with errors.
>IMHO the developers should try to work around this, so that the round()
>function works the same way on all platforms.

My experience with mysql doesn't go back very far.  Thus, I excuse myself for missing 
the change in rounding behavior 
between versions.  Now that I'm done "crawdadding"...

I agree completely.  :)


>The other bug is related to the preparation of the statement. It seems the
>number of decimals in the output column is decided once before the actual
>query is performed, and this number is fixed:
>
>mysql> select *,round(num1,id) from tab4;
>+------+----------+----------------+
>| id   | num1     | round(num1,id) |
>+------+----------+----------------+
>|    1 |   1.2345 |         1.2000 |
>|    2 |  12.3456 |        12.3500 |
>|    3 | 100.4235 |       100.4230 |
>+------+----------+----------------+
>3 rows in set (0.01 sec)
>
>The parser tries to decide the number of decimals _before_ the query is
>executed, but as 'id' does not make any sense at that point, the number of
>decimals in the num1 parameter (4) is used... then, for each row, the
>round() function is executed with the correct parameters, and the result is
>"correct" (if we ignore the rounding error), but is then padded with zeroes,
>so that the total number of decimals is four. This padding makes the result
>wrong, as "1.2000" is not the same as "1.2" when we talk about human
>readable numbers. (The first indicate a higher grade of precision.)
>

You're absolutely right on the matter of interpretation by humans and I failed to 
consider that when I concluded the 
display of the rounded values was acceptable.  Problem was, we knew the original 
values and were not receiving them as 
the only set.  But, I view this as a design oversight that should be addressed rather 
than as a bug.

Doug






---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to