"Andrew Kuebler" <[EMAIL PROTECTED]> wrote on 23/01/2004 17:13:13:

> Can anyone explain why:
>
> SELECT ROUND(.012345, 5)
> -> .01234
>
> Why doesn't mysql round the 5 up to .01235? How do I get it to round up?
> I've tried manipulating ceil, floor, round and truncate and I can't seam
> to find an easy way to do this.
>
> I read in the manual that this behavior depends on the C library
> implementation, but how do you change it? To me, this is not normal
> behavior. Can anyone help? Thanks in advance...

As stated in the manual, the behaviour of rounding a final digit 5 varies
with the C library. To change it you need to relink with a different C
library.

If I remember correctly, Unix rounds up, whereas Windows rounds towards
even.

Both behaviours can be justified. The Unix behaviour is justifiable on the
grounds that the (unknown) digits after the closing 5 in a floating point
calculation are most unlikely to be exactly zero, and therefore rounding up
is more likely to be correct than rounding down. The Windows behaviour is
justified by saying that this will introduce a bias into the rounding, so
that the sum of a large number of rounded numbers will always be larger
than the rounded sum of those numbers. If this is, for example, an interest
calculation, more interest will be paid than is stricly necessary. By
rounding towards even, this bias is removed in a determinate and arguably
fair manner. To some extent, it depends uponn your application which is
right: engineering vs. finance.

Your system appears to be showing Windows behaviour. You could, I suppose,
try rebuilding MySQL under Cygwin to get Unis-style behaviour. But this
seems a sledgehammer to crack a nut.

      Alec Cawley



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to