I haven't found a direct answer for this (yet), (see Update below) but it's interesting that if you assign the math to another variable first, then print that variable, the number is printed correctly; for example:
$i = 2; $j = (1-1/2000)**$i; print $j;
The output is:
0.99900025
It seems that the print function is interpreting the number differently due to the parens. If you input a similar math problem directly into print, but without parens, the number comes out right.
$i = 2; print 0.9995**$i;
Output:
0.99900025
Update: print is only printing what is in the parens because it is treating that part like the complete input to a function, ignoring the exponent part. Adding the blank string in front changes print to list operator mode, printing the entire answer.
To summarize: the two modes of print are:
# function mode print (your code here);
And
# list mode print arg1, arg2, etc; # and/or the . operator
In reply to Re: strange arithmetic
by nlwhittle
in thread strange arithmetic
by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |