Re: [RFC] Config setting to force all math operations to pass through BCMath library.
| From: | Daniel Macedo | Date: | Tue, 06 Mar 2012 22:12:49 +0000 |
| Subject: | Re: [RFC] Config setting to force all math operations to pass through BCMath library. | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-58696@lists.php.net to get a copy of this message | ||
On Tue, Mar 6, 2012 at 22:05, Michael Morris <dmgx.michael@gmail.com> wrote:
> I do use it. It's a pain in the ass to read because you have to LISP
> nest all the operations. You 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 = 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