12 messages in com.mysql.lists.bugsRe: TRUNCATE() question| From | Sent On | Attachments |
|---|---|---|
| john r. durand | 08 Jan 2003 00:08 | |
| Christian Kohlschütter | 08 Jan 2003 00:40 | |
| Christian Kohlschütter | 08 Jan 2003 00:49 | |
| john r. durand | 08 Jan 2003 06:32 | |
| Peter Zaitsev | 09 Jan 2003 14:02 | |
| john r. durand | 09 Jan 2003 21:08 | |
| Peter Zaitsev | 10 Jan 2003 04:55 | |
| john r. durand | 28 Jan 2003 05:33 | |
| Peter Zaitsev | 28 Jan 2003 06:06 | |
| Mary Stickney | 28 Jan 2003 07:21 | |
| Peter Zaitsev | 28 Jan 2003 07:27 | |
| Sergei Golubchik | 28 Jan 2003 07:39 |
| Subject: | Re: TRUNCATE() question![]() |
|---|---|
| From: | Sergei Golubchik (se...@mysql.com) |
| Date: | 01/28/2003 07:39:45 AM |
| List: | com.mysql.lists.bugs |
Hi!
On Jan 28, Peter Zaitsev wrote:
On Tuesday 28 January 2003 16:34, john r. durand wrote:
i'm having an issue with TRUNCATE() (used rather than ROUND() which doesn't do what i need).
I'm really sorry to upset you once again, but it is not the bug. It is floating point in its worst :)
It is not guarantied 0.05 would be presented as 0.05 insed of floating point number. It may something like 0.04999998756
I would like to add, that it's how perl behaves too:
% perl -e 'print " ", ((13.0) * 0.085), "\n" ' 1.105 % perl -e 'print " ", ((13.0) * 0.085)+0.005, "\n" ' 1.11 % perl -e 'print " ", int((((13.0) * 0.085)+0.005)*100)/100, "\n"' 1.1 % perl -e 'print " ", int((((13.0) * 0.085)+0.0051)*100)/100, "\n"' 1.11 %
This behaviour is unavoidable deficiency of binary fixed-precision representation of real decimal numbers. :(
Regards, Sergei
-- MySQL Development Team __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Sergei Golubchik <se...@mysql.com> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, http://www.mysql.com/ /_/ /_/\_, /___/\___\_\___/ Osnabrueck, Germany <___/




