PREP 2015 Question Authoring - Archived

Errors resulting from variable assignments using base e.

Re: Errors resulting from variable assignments using base e.

by Davide Cervone -
Number of replies: 0
In your list of expressions that are accepted, only the two assignments that involve Compute() actually produce what you are looking for. They others may not produce an error message, but they don't compute the correct value. That is because e is not a predefined value in Perl, and so it is treated as an unquoted string. In some situations, that string is converted to a number by turning it into a zero, but in other cases, it causes a syntax error. But even when it doesn't the answer you get won't be what you expect.

Only inside a Compute() string is e defined as you would expect. We will talk more about these issues on Monday.

In perl code, you could do

$e = exp(1);
$a = ($k1*$d*$e);
for example. There is also a constant $E defined by PG that you could use (if you don't mind the capitalization difference).