Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11508 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69339 invoked by uid 1010); 23 Jul 2004 11:32:42 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 69249 invoked from network); 23 Jul 2004 11:32:42 -0000 Received: from unknown (HELO xaxa.search.ch) (195.141.85.117) by pb1.pair.com with SMTP; 23 Jul 2004 11:32:42 -0000 Received: from localhost (localhost [127.0.0.1]) by xaxa.search.ch (Postfix) with ESMTP id C19776D36E; Fri, 23 Jul 2004 13:32:41 +0200 (CEST) Received: by xaxa.search.ch (Postfix, from userid 65534) id 9849C6D8AC; Fri, 23 Jul 2004 13:32:40 +0200 (CEST) Received: from [192.168.1.72] (ultrafilter-i [192.168.85.2]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by xaxa.search.ch (Postfix) with ESMTP id 737DD6D36E; Fri, 23 Jul 2004 13:32:39 +0200 (CEST) Message-ID: <4100F756.3080000@cschneid.com> Date: Fri, 23 Jul 2004 13:32:38 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040617 X-Accept-Language: en-us, en, de-ch MIME-Version: 1.0 To: George Whiffen Cc: internals@lists.php.net References: <20040723080319.74978.qmail@pb1.pair.com> <4100DB8A.2000003@cschneid.com> <20040723105532.30754.qmail@pb1.pair.com> In-Reply-To: <20040723105532.30754.qmail@pb1.pair.com> X-Enigmail-Version: 0.84.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on xaxa.search.ch X-Spam-Level: X-Spam-Status: No, hits=-4.9 required=5.0 tests=BAYES_00 autolearn=ham version=2.63 X-Virus-Scanned: by AMaViS 0.3.12pre8 Subject: Re: fp, rounding, decimal arithmetic - definitive account? From: cschneid@cschneid.com (Christian Schneider) Hey George, My point is: I'm not against improving accuracy of floating point arithmetic in PHP (although it could lead to some weird compatibility problems with older version) but I wouldn't advise people who really, really have to rely on their numbers to be correct to use floats anyway. George Whiffen wrote: > Exactly my point. When coding php you need floating point you can > trust or it is useless. As I said, bc is probably the best currently You can never trust floating point if you need both big numbers and precision at the same time. Floating point is always a trade off between the two. > If I'm wrong, and it's really only bc that can be trusted to add 0.1 > and 0.1, then shouldn't we be using that internally, rather than > pretending to have a useable fp decimal arithmetic? Floating point (even the current PHP implementation) is fine if you're happy enough with approximations which is the case 99% of the time. > P.S. I'm interested that you have money numbers so big that 15 digits > are not enough. It can't be gross world income which still isn't up I store cent values as integer strings and I possibly have to deal with values bigger than 214 million bucks (where PHP starts to convert ints to float) so I decided to go for BC Math. I didn't even care to check what the range/precision limits of floats are as I wanted something absolutely predictable, no matter what numbers are put into the system by our customers. Just because you're paranoid doesn't mean they're not after you :-) - Chris