Index: trunk/extensions/ParserFunctions/Expr.php |
— | — | @@ -157,8 +157,6 @@ |
158 | 158 | |
159 | 159 | if ($haveBC === null) { |
160 | 160 | $haveBC = extension_loaded( 'bcmath' ); |
161 | | - if ($haveBC) // Set to precision of 14. |
162 | | - bcscale(16); |
163 | 161 | } |
164 | 162 | |
165 | 163 | return $haveBC; |
— | — | @@ -178,6 +176,11 @@ |
179 | 177 | # Unescape inequality operators |
180 | 178 | $expr = strtr( $expr, array( '<' => '<', '>' => '>', |
181 | 179 | '−' => '-', '−' => '-' ) ); |
| 180 | + |
| 181 | + ## initialise BC |
| 182 | + if ( $this->haveBC() ) { |
| 183 | + bcscale(16); |
| 184 | + } |
182 | 185 | |
183 | 186 | $p = 0; |
184 | 187 | $end = strlen( $expr ); |
— | — | @@ -582,10 +585,7 @@ |
583 | 586 | if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]); |
584 | 587 | $arg = array_pop( $stack ); |
585 | 588 | if ( $arg <= 0 ) throw new ExprError('invalid_argument_ln', $this->names[$op]); |
586 | | - if ($haveBC) // ln(x) = 1^(1/e) |
587 | | - $stack[] = bcpow( $arg, bcdiv( 1, exp(1) ) ); |
588 | | - else |
589 | | - $stack[] = log($arg); |
| 589 | + $stack[] = log( doubleval($arg) ); |
590 | 590 | break; |
591 | 591 | case EXPR_ABS: |
592 | 592 | if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]); |