Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58696 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87570 invoked from network); 6 Mar 2012 22:13:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Mar 2012 22:13:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=admacedo@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=admacedo@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: admacedo@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gy0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:50249] helo=mail-gy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E0/91-15021-B0C865F4 for ; Tue, 06 Mar 2012 17:13:31 -0500 Received: by ghbg2 with SMTP id g2so2900379ghb.29 for ; Tue, 06 Mar 2012 14:13:29 -0800 (PST) Received-SPF: pass (google.com: domain of admacedo@gmail.com designates 10.236.184.129 as permitted sender) client-ip=10.236.184.129; Authentication-Results: mr.google.com; spf=pass (google.com: domain of admacedo@gmail.com designates 10.236.184.129 as permitted sender) smtp.mail=admacedo@gmail.com; dkim=pass header.i=admacedo@gmail.com Received: from mr.google.com ([10.236.184.129]) by 10.236.184.129 with SMTP id s1mr37763201yhm.21.1331072009284 (num_hops = 1); Tue, 06 Mar 2012 14:13:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=tn1JmGTNLj3CSDYCk5VQqW7TEJwnHemFioQCeaEkfiY=; b=EnOHz9MwGx5CJxleSflIcrZEKDzbIv4gqVLrcPjr1mk7mrDjgGT0clSVhBMSJxqUaJ Ouip0jtfS34x5D3SX5USPmXnMOGi7WIFMoFclKelRKFt6LjMuyVEqnyDt9nMIo37xmgy A0PBe2+5g7uPLnx1nXbrHGPq3josBB5Ok5R9vgpTBKcm89YNsROL1Z39M7dRDhMYCiBO /qPZ9LfD+L+V6IMA1BJ4+Q2kT0MESR16ier0M7Y51duigZtq5tfkJbZE8P9WqX+Acvp+ cJeBCqd75ThKqaPBczyIbCVATUzK2dunnioGV2ut4fKmwUJrOyLt81Y0awIeH9whEL1K kZOw== Received: by 10.236.184.129 with SMTP id s1mr29941404yhm.21.1331072009235; Tue, 06 Mar 2012 14:13:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.180.70 with HTTP; Tue, 6 Mar 2012 14:12:49 -0800 (PST) In-Reply-To: References: <59884.5975f635.1331070466.nsm@avilys.eik.lt> Date: Tue, 6 Mar 2012 22:12:49 +0000 Message-ID: To: Michael Morris Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Config setting to force all math operations to pass through BCMath library. From: admacedo@gmail.com (Daniel Macedo) On Tue, Mar 6, 2012 at 22:05, Michael Morris wrote= : > I do use it. =A0It's a pain in the ass to read because you have to LISP > nest all the operations. =A0You can't tell me this is easy or intuitive > to read... > > bcadd( bcsub( $bill['penalty'], $bill['rounding'], 2),bcmul( > $bill['taxdue'], bcmul( $penalty, $monthsAhead, 2 ), 2 ), 2 ) > > Compared to > > $bill['penalty'] - $bill['rounding'] + $bill['taxdue'] * $penalty * > $monthsAhead; > > You can do it, but it's eye bleeding. I agree with you, how about having the bcmath extension support a more general (and even better, non-BC-breaking) function supporting the order of math operations (and maybe even math functions)... Something like a bc(string $operations [, int $scale =3D 2]) Supporting passing: bc("(29.99 + $a) * $b - pow(10, $c) / 2"); Came across something like that in the manual: http://php.net/ref.bc#107014 How's that for a quick 'n dirty idea to solve this issue? ~ Daniel Macedo