| … | |
… | |
| 3370 | # |
3370 | # |
| 3371 | |
3371 | |
| 3372 | =head4 math_constants |
3372 | =head4 math_constants |
| 3373 | |
3373 | |
| 3374 | replaces pi, e, and ^ with their Perl equivalents |
3374 | replaces pi, e, and ^ with their Perl equivalents |
|
|
3375 | if useBaseTenLog is non-zero, convert log to logten |
| 3375 | |
3376 | |
| 3376 | =cut |
3377 | =cut |
| 3377 | |
3378 | |
| 3378 | sub math_constants { |
3379 | sub math_constants { |
| 3379 | my($in,%options) = @_; |
3380 | my($in,%options) = @_; |
| … | |
… | |
| 3386 | # The code fragment above allows this filter to be used when the input is simply a string |
3387 | # The code fragment above allows this filter to be used when the input is simply a string |
| 3387 | # as well as when the input is an AnswerHash, and options. |
3388 | # as well as when the input is an AnswerHash, and options. |
| 3388 | $in =~s/\bpi\b/(4*atan2(1,1))/ge; |
3389 | $in =~s/\bpi\b/(4*atan2(1,1))/ge; |
| 3389 | $in =~s/\be\b/(exp(1))/ge; |
3390 | $in =~s/\be\b/(exp(1))/ge; |
| 3390 | $in =~s/\^/**/g; |
3391 | $in =~s/\^/**/g; |
|
|
3392 | if($main::useBaseTenLog) { |
|
|
3393 | $in =~ s/\blog\b/logten/g; |
|
|
3394 | } |
| 3391 | |
3395 | |
| 3392 | if ($process_ans_hash) { |
3396 | if ($process_ans_hash) { |
| 3393 | $rh_ans->{student_ans}=$in; |
3397 | $rh_ans->{student_ans}=$in; |
| 3394 | return $rh_ans; |
3398 | return $rh_ans; |
| 3395 | } else { |
3399 | } else { |