note 26761 deleted from function.round by didou

From: Date: Wed, 17 Sep 2003 01:00:47 +0000
Subject: note 26761 deleted from function.round by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-56597@lists.php.net to get a copy of this message
Note Submitter: dpatton@no.spam.confluence.org ---- The round() function doesn't "work properly" for some values. Here's an example from a posting on the mailing list: http://groups.google.com/groups ?selm=aevg53%2420ru%241%40FreeBSD.csie.NCTU.edu.tw Matthew Clark wrote: Seeing as the mathematically correct way to round numbers is to round down to n for n-1<=m<=n.5 and up to n+1 for n.5<m<n+1, I wonder why the PHP round() function couldn't include a little 'fuzz' to handle the rounding problems we encounter due to floating point representation in the hardware? It could even be a configurable option - but it would save writing a wrapper... Matthew, I can't agree with you more. I really don't understand the point of php having a round function which gives the wrong answer on even very simple decimals e.g. round(0.35,1) returns 0.3. [snip] Regards, George

« previous php.notes (#56597) next »