12 messages in com.mysql.lists.bugsRe: TRUNCATE() question
FromSent OnAttachments
john r. durand08 Jan 2003 00:08 
Christian Kohlschütter08 Jan 2003 00:40 
Christian Kohlschütter08 Jan 2003 00:49 
john r. durand08 Jan 2003 06:32 
Peter Zaitsev09 Jan 2003 14:02 
john r. durand09 Jan 2003 21:08 
Peter Zaitsev10 Jan 2003 04:55 
john r. durand28 Jan 2003 05:33 
Peter Zaitsev28 Jan 2003 06:06 
Mary Stickney28 Jan 2003 07:21 
Peter Zaitsev28 Jan 2003 07:27 
Sergei Golubchik28 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