On Wed, 27 Feb 2002 13:53:15 +0100, Roger Baklund wrote: >* Doug Thompson
>> I found using variables to work as expected with 3.23.43 and Win98. >> >> I was unable to duplicate your changing outputs. > >I was using a 3.23.30-gamma win2k. > >> mysql> select @a:=digits,number,round(number,@a) from testme; >> +------------+----------+------------------+ >> | @a:=digits | number | round(number,@a) | >> +------------+----------+------------------+ >> | 3 | 100.4235 | 100.4230 | >> | 1 | 85.4000 | 85.4000 | >> +------------+----------+------------------+ >> 2 rows in set (0.00 sec) > >Wouldn't you expect the output to be something like: > > +------------+----------+------------------+ > | @a:=digits | number | round(number,@a) | > +------------+----------+------------------+ > | 3 | 100.4235 | 100.423 | > | 1 | 85.4000 | 85.4 | > +------------+----------+------------------+ No, I would expect the output to inherit the field type of "number" and display the same way. > >also.... 100.423... should it not be 100.424? As you know, some systems/packages round down 0.xx50 while other round up from that value. I agree that intuitively it should round up, but it is only a matter about which we need to be aware unless the application is critical -- control systems come to mind -- and then you compensate in the software design if it's needed. It's a function of how the floating point hardware performs storage and manipulation of values in response to the instructions and how the software processes the calls. It is reasonable to expect consistent behavior within a given processor family, but that's about all we can hope for. For example, I'm running an AMD K6/2-500 processor. Your system likely has an Intel cpu. Then there are still different results from a Sun system. Your results brought the issues to light. I wonder if there's a reasonable fix. > >This is still my win2k 3.23.30-gamma: > >mysql> select round(100.4234,3),round(100.4235,3),round(100.42350001,3); >+-------------------+-------------------+-----------------------+ >| round(100.4234,3) | round(100.4235,3) | round(100.42350001,3) | >+-------------------+-------------------+-----------------------+ >| 100.423 | 100.423 | 100.424 | >+-------------------+-------------------+-----------------------+ >1 row in set (0.00 sec) > >The same statement on solaris 3.23.39-log: > >mysql> select round(100.4234,3),round(100.4235,3),round(100.42350001,3); >+-------------------+-------------------+-----------------------+ >| round(100.4234,3) | round(100.4235,3) | round(100.42350001,3) | >+-------------------+-------------------+-----------------------+ >| 100.423 | 100.424 | 100.424 | >+-------------------+-------------------+-----------------------+ >1 row in set (0.05 sec) > >-- >Roger Just when we thought it might be safe to go in the water ;-) Regards, Doug >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