From owner-freebsd-questions@FreeBSD.ORG Wed Apr 12 10:09:28 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 09A4D16A401 for ; Wed, 12 Apr 2006 10:09:28 +0000 (UTC) (envelope-from nakiel@nakiel.dyndns.org) Received: from nakiel.dyndns.org (abzr90.neoplus.adsl.tpnet.pl [83.9.63.90]) by mx1.FreeBSD.org (Postfix) with ESMTP id 94B6943D45 for ; Wed, 12 Apr 2006 10:09:27 +0000 (GMT) (envelope-from nakiel@nakiel.dyndns.org) Received: by nakiel.dyndns.org (e-generation, from userid 1000) id 73FAA5087A; Wed, 12 Apr 2006 12:09:17 +0200 (CEST) Date: Wed, 12 Apr 2006 12:09:17 +0200 From: Krzysztof Nakielski To: freebsd-questions@freebsd.org Message-ID: <20060412100917.GA1406@nakiel.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Subject: 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: Wed, 12 Apr 2006 10:09:28 -0000 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 %php -r 'print round(8.085, 2) ."\n";' 8.09 %php -r 'print round(0.075, 2) ."\n";' 0.08 Python (2.4.2): >>> print "%.2f" % round(8.075, 2) 8.07 >>> print "%.2f" % round(8.085, 2) 8.09 >>> print "%.2f" % round(1.075, 2) 1.08 mysql (4.1.18): +-----------------+ | round(8.075, 2) | +-----------------+ | 8.07 | +-----------------+ +-----------------+ | round(8.085, 2) | +-----------------+ | 8.09 | +-----------------+ +-----------------+ | round(6.075, 2) | +-----------------+ | 6.08 | +-----------------+ In PostgreSQL everything seems to be ok. Is this function wrong implemented in php, python, mysql? Thanks, -- * Krzysztof Nakielski * * System Administrator *