in reply to strange arithmetic
Your codeprobably doesn't do what you expect at first glance. The parentheses enclose the argument list for print which is evaluated (printing the result of $foo & 255 ). Then one is added to the return value of print (usually 1). The result is something like this:print ($foo & 255) + 1, "\n";To do what you meant properly, you must write:1 + 1, "\n"; # Obviously not what you meant.print(($foo & 255) + 1, "\n");
is functionally equivalent toprint (1-1/2000)**$i;
and not(print (1-1/2000))**$i;
as you might think. The parentheses bind tighter to the print than to the exponentiation operator.print ((1-1/2000)**$i);
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: strange arithmetic
by morgon (Priest) on Jan 09, 2015 at 21:37 UTC | |
by RonW (Parson) on Jan 09, 2015 at 22:44 UTC |