On 09/14/2006 06:47 PM, Bryan R Harris wrote:

Can someone explain this behavior?

% perl -e 'print -12.17**0.2, "\n"'
-1.64838295714428
% perl -e 'print (-12.17)**(0.2), "\n"'
-12.17% perl -e 'print ((-12.17)**(0.2)), "\n"'
nan%


Yes, the "\n" isn't getting printed for some reason on the 2nd two examples.
Bottom line:

-12.17**0.2  ==> -1.65
(-12.17)**(0.2) ==> -12.17
((-12.17)**(0.2)) ==> nan

I have absolutely zero idea what could be going on here...  Please help!

- B





$ perl -e 'print (-12.17**0.2, "\n")'
-1.64838295714428
$ perl -e 'print ((-12.17)**0.2, "\n")'
nan
$ perl -e 'print (-1*(12.17)**0.2, "\n")'
-1.64838295714428
$ perl -e 'print ((-1)**0.2, "\n")'

The "\n" was outside of "print's" parenthises, and, evidently, perl does not like applying fractional exponents to negative numbers.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to