Hi this is my first post here please don't shoot if i do something wrong ;) This is what i'm doing: I'm trying to write a method that solves for the powers of complex numbers. I know that there are modules available for this, but for my current situation, using those modules aren't practical, so I am forced to write my own. this is my code:
#FINDS THE COMPLEX ARGUMENT #PRETTY SURE THIS WORKS TOO sub argComplex { my $value1, $real1, $complex1; $value1 = @_[0]; @construct = &constructComplex($value1); $real1= @construct[0]; $complex1 = @construct[2]; return atan2($complex1, $real1); } $real1 = 1; $z = 1 + i; #LOOK HERE #RETURNS ZERO #I DON'T KNOW WHY #BY ITSELF, argComplex($z) RETURNS 0.7854, WHICH IS RIGHT ACCORDING TO + MATLAB print $real1 * argComplex($z);
when the print function goes through, it prints 0 instead of the right answer. I'm convinced there is some weird rule in Perl that I'm not following.
If you get it to print $real1, it prints 1
If you get it to print argComplex($z), it prints .7854
but if you get it to print $real1 * argComplex($z), it prints Zero
Please Help
Thanks,
Donnell

In reply to Weird Perl Rule I'm Probably Not Following by moltar512

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.