Attila Soki wrote: > select round(9.065,2) > +----------------+ > | round(9.065,2) | > +----------------+ > | 9,06 | > +----------------+ > > why not 9,07 ??
Most C compilers today defer things like round() to the floating-point unit on the CPU. Most CPUs these days implement IEEE754 as their FP standard, and IEEE 754 defines several "rounding modes" that the processor can be set to to define the behavior of the round operation. The default (usually) is "round to nearest even" (which is what the others have pointed out). You can also set it to "round towards zero", "round away from zero", or "round towards minus infinity". The application is supposed to know what behavior it prefers, and set the default rounding behavior on the FPU by using a specific control instruction. The operating systems are supposed to cooperate by saving and restoring the process' FP rounding preference when restarting the process after an interrupt. Needless to say, there's a fair amount of confusion on this front, and certainly no portable solution, though I believe the latest C standard (C99) has some APIs to control this. The only other choice is to never depend on the FPU rounding, but always call a software FP round routine to perform your rounding, if it's that important. MySQL hasn't done this (and neither have any of the other DB packages I've used recently). -- Shankar. --------------------------------------------------------------------- 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