in reply to Re^2: root function
in thread root function

sini@ordinalfabetix:~$ perl -le"print ((-3)**(1/3));" nan sini@ordinalfabetix:~$

Exponent operator ** has higher priority than unary minus so you are doing -(3**(1/3)) instead of ((-3)**(1/3)).

This gives you accidentally the right result but it would tell you that square root of -2 == -1.414265...

Careful with that hash Eugene.

Replies are listed 'Best First'.
Re^4: root function
by ikegami (Patriarch) on Jun 21, 2008 at 21:58 UTC

    Too slow!

    This gives you accidentally the right result but it would tell you that square root of -2 == -1.414265...

    But -1.414265... is a square root of 2. :)

    Update: Ack! ignore this post.

      More to the point: it is not the square root of -2.

      sas

      Too slow?

      No, it is only that if I wait before answering, my answers worth more... proposition for Voting system :)

      Careful with that hash Eugene.