* Doug Thompson > On Thu, 28 Feb 2002 22:38:04 -0000, DL Neil wrote: > > >I know it's getting late, so perhaps I'm not following you sufficiently > >closely. What does "inherited" mean? > > > > "Inherited" referred to using the float(10,4) formatting of the > "numbers" field in this case.
It seems the highest number of decimals used in the X expression of the round(X,D) is used in the result row: mysql> select round(number+0.000000000,digits) from testme; +----------------------------------+ | round(number+0.000000000,digits) | +----------------------------------+ | 100.423000000 | | 85.400000000 | +----------------------------------+ 2 rows in set (0.00 sec) This is consistent with the mysql behaviour in any decimal related operations: mysql> select 1.20*1.0000; +-------------+ | 1.20*1.0000 | +-------------+ | 1.2000 | +-------------+ 1 row in set (0.00 sec) ...and this is also the right thing to do, if I remember my school math. But it is not the right thing to do for the result of the round() function. > > Also how do you define "worked". > Good question. I meant that it functions in the same manner on > both machines. And it is wrong on both machines... :o) > However, your question caused me to go back for another look. I > found that when a constant instead of a column_id or @variable is > inserted for D (round(X,D)) then the output decimal length is > truncated to the value of the constant which is consistent with the > manual. This is also the behavior that Roger was asking me to > recognize but I had on my really dark glasses. > > Interestingly, if a floating point number is entered as the > constant, it is apparently correctly rounded up from .50 before being > applied to the calculation. Yes, this was interresting... win2k, 3.23.30-gamma: mysql> select round(2.5); +------------+ | round(2.5) | +------------+ | 2 | +------------+ 1 row in set (0.00 sec) mysql> select round(number,2.5) from testme; +-------------------+ | round(number,2.5) | +-------------------+ | 100.423 | | 85.400 | +-------------------+ 2 rows in set (0.00 sec) So, when using 2.5 for the D parameter in round(X,D) on a machine with the buggy C lib, it is rounded up to 3, even if the result of round(2.5) is 2...!? The round() function must be using a different rounding algorithm when evaluating the D parameter...? -- Roger query --------------------------------------------------------------------- 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