[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Antwort: decimal(8,2) rounding bug or still "to be expected" behaviour?
On 09.03.2001 10:29:28 Christian Hammers wrote:
> Is this a bug or is the decimal type just evil or how should *I* behave
> when having such a table?
If I'm not mistaken, then decimal is handled internally like a float. And as
such, problems like yours are really expected, because there simply is no way to
store *EXACTLY* -0.01 in a float. You can get close to it, but you'll never
reach -0.01 - you'll either be a tiny bit above or below the value. So, when
MySQL then rounds (? or truncates?) to have only 2 values after the .
To come around this, you may multiply the value by hundred and convert it to an
integer value. Or you check if it is <(-0.0000000000000000000001) AND >
0.0000000000000001
---------------------------------------------------------------------
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 <mysql-thread67777@xxxxxxxxxxxxxxx>
To unsubscribe, e-mail <mysql-unsubscribe-treed=ultraviolet.org@xxxxxxxxxxxxxxx>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
This mailing list archive is a service of Copilot Consulting.