Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58697 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90053 invoked from network); 6 Mar 2012 22:41:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Mar 2012 22:41:59 -0000 Authentication-Results: pb1.pair.com header.from=tom@punkave.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tom@punkave.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain punkave.com designates 209.85.210.170 as permitted sender) X-PHP-List-Original-Sender: tom@punkave.com X-Host-Fingerprint: 209.85.210.170 mail-iy0-f170.google.com Received: from [209.85.210.170] ([209.85.210.170:50036] helo=mail-iy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/F1-15021-5B2965F4 for ; Tue, 06 Mar 2012 17:41:58 -0500 Received: by iaeh11 with SMTP id h11so8538682iae.29 for ; Tue, 06 Mar 2012 14:41:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.196.165 with SMTP id in5mr3305418igc.8.1331073715688; Tue, 06 Mar 2012 14:41:55 -0800 (PST) Received: by 10.231.152.85 with HTTP; Tue, 6 Mar 2012 14:41:55 -0800 (PST) In-Reply-To: References: <59884.5975f635.1331070466.nsm@avilys.eik.lt> Date: Tue, 6 Mar 2012 17:41:55 -0500 Message-ID: To: Daniel Macedo Cc: Michael Morris , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQn1O7BVzaZd3Wye7VEzauf3LtvDGJk9CwxwLs39Kyg4sgJgRLDotazmzNyZ0YwyrnBEquD/ Subject: Re: [PHP-DEV] [RFC] Config setting to force all math operations to pass through BCMath library. From: tom@punkave.com (Tom Boutell) Excellent idea. bcmath is already not the highest performance thing in the world, so adding a function that parses a more reasonable looking expression would not be an unacceptable compromise for most. It also doesn't give you the false impression that since operators do the right thing functions are going to do the right thing too. That's very muddy and confusing. On Tue, Mar 6, 2012 at 5:12 PM, Daniel Macedo wrote: > On Tue, Mar 6, 2012 at 22:05, Michael Morris wro= te: >> 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#1070= 14 > How's that for a quick 'n dirty idea to solve this issue? > > ~ Daniel Macedo > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --=20 Tom Boutell P'unk Avenue 215 755 1330 punkave.com window.punkave.com