From owner-freebsd-questions@FreeBSD.ORG Thu Apr 13 09:22:39 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A3FE316A400 for ; Thu, 13 Apr 2006 09:22:39 +0000 (UTC) (envelope-from nakiel@nakiel.dyndns.org) Received: from nakiel.dyndns.org (abyy164.neoplus.adsl.tpnet.pl [83.9.44.164]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1904D43D45 for ; Thu, 13 Apr 2006 09:22:38 +0000 (GMT) (envelope-from nakiel@nakiel.dyndns.org) Received: by nakiel.dyndns.org (e-generation, from userid 1000) id 09EC25094C; Thu, 13 Apr 2006 11:22:27 +0200 (CEST) Date: Thu, 13 Apr 2006 11:22:26 +0200 From: Krzysztof Nakielski To: Bill Moran Message-ID: <20060413092226.GA10039@nakiel.dyndns.org> References: <20060412100917.GA1406@nakiel.dyndns.org> <20060412093701.0309d4a6.wmoran@collaborativefusion.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline In-Reply-To: <20060412093701.0309d4a6.wmoran@collaborativefusion.com> User-Agent: Mutt/1.4.2.1i Cc: freebsd-questions@freebsd.org Subject: Re: round() problem X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Apr 2006 09:22:39 -0000 On Wed, Apr 12, 2006 at 09:37:01AM -0400, Bill Moran wrote: > On Wed, 12 Apr 2006 12:09:17 +0200 > Krzysztof Nakielski wrote: > > > Hi, > > > > I am having problem with round() function in php, python, mysql. I am > > not sure if thats FreeBSD issue. I receive the same results on 4.11, 5.4 > > and 6.0. > > > > php (4.4.1, 5.1.2): > > %php -r 'print round(8.075, 2) ."\n";' > > 8.07 > > Have you compared these results to other POSIX systems? On RHEL 3 only PHP returns good result. In python and mysql there is the same issue. > The problem is in the way that real numbers are implemented. If you > do some searches, you'll find many, many discussions of this. Simple > fact is that the behaviour under these circumstances is not what > you think it is. This kind of thing is the reason that most languages > have high-precision floating point libraries available. > I will search for this. But first thing is to give up with python, php, mysql in billing software or write own functions otherwise you can lose money. Thanks, -- * Krzysztof Nakielski * * System Administrator *