QUOTE(dsherohman @ 30 Oct, 2009 - 05:03 AM)

QUOTE(romeyb1105 @ 30 Oct, 2009 - 03:32 AM)

CODE
$v = (8*$a*$b) - ($c/4) >> 17.32;
I can enter the numbers just fine, but the output always comes to zero. What's the next step I need to take in order to get the program to calculate the above equation?
It's calculating it correctly, exactly as you specified it... but ">>" is probably not doing what you think it is.
From 'man perlop':
QUOTE
Binary ">>" returns the value of its left argument shifted right by the
number of bits specified by the right argument. Arguments should be
integers. (See also "Integer Arithmetic".)
You've told Perl to calculate the value of (8*$a*$b ) - ($c/4)... and then shift the result right by 17.32 bits. Assuming Perl rounds the 17.32 down to 17, this is roughly equivalent to dividing by 131,072 (which is 2^17) and rounding down. If (8*$a*$b ) - ($c/4) is larger than 131,072, then you should get a non-zero result.
So what did you intend the ">>" to do?
QUOTE(dsherohman @ 30 Oct, 2009 - 05:03 AM)

QUOTE(romeyb1105 @ 30 Oct, 2009 - 03:32 AM)

CODE
$v = (8*$a*$b) - ($c/4) >> 17.32;
I can enter the numbers just fine, but the output always comes to zero. What's the next step I need to take in order to get the program to calculate the above equation?
It's calculating it correctly, exactly as you specified it... but ">>" is probably not doing what you think it is.
From 'man perlop':
QUOTE
Binary ">>" returns the value of its left argument shifted right by the
number of bits specified by the right argument. Arguments should be
integers. (See also "Integer Arithmetic".)
You've told Perl to calculate the value of (8*$a*$b ) - ($c/4)... and then shift the result right by 17.32 bits. Assuming Perl rounds the 17.32 down to 17, this is roughly equivalent to dividing by 131,072 (which is 2^17) and rounding down. If (8*$a*$b ) - ($c/4) is larger than 131,072, then you should get a non-zero result.
So what did you intend the ">>" to do?
I must've misunderstood how the shift operators work. I'm trying to do the Please Excuse My Dear Aunt Sally method of the equation so I can get the correct answer.