Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14698 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52718 invoked by uid 1010); 7 Feb 2005 20:39:57 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 52627 invoked by uid 1007); 7 Feb 2005 20:39:55 -0000 Message-ID: <20050207203954.52626.qmail@lists.php.net> To: internals@lists.php.net Date: Mon, 7 Feb 2005 21:39:20 +0100 Lines: 29 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Posted-By: 212.238.144.71 Subject: is the bankers' round() algorithm implemented well? From: r.korving@xit.nl ("Ron Korving") I understood that round() is using the so called Bankers' round algorithm. But I notice it's inconsistent. The banker's algorithm is magically activated only for numbers beyond 2047.0. Before 2047, the "classic" 5-is-rounded-up method is used. 5 is rounded up for: round(9.005, 2) gives 9.01 round(9.015, 2) gives 9.02 round(9.025, 2) gives 9.03 round(9.035, 2) gives 9.04 round(2047.005, 2) gives 2047.01 round(2047.015, 2) gives 2047.02 round(2047.025, 2) gives 2047.03 round(2047.035, 2) gives 2047.04 bankers' rounding: round(2048.005, 2) gives 2048.01 round(2048.015, 2) gives 2048.01 round(30000.005, 2) gives 30000.01 round(30000.015, 2) gives 30000.01 This can't be intentional, can it? Someone tell me if this is a bug or a feature please. Ron