Hello!

I was just implementing this small program for calculating the line-
equation, given two points.
Just in case you don't remind this equation.... y = slope * x + b.
First I calculate the slope and then b:

$slope = ($ARGV[1] - $ARGV[3]) / ($ARGV[0] - $ARGV[2]);
$b = $ARGV[1] - ($ARGV[0] * $slope);
print "\n$ARGV[1] = $slope * $ARGV[0] + $b\n";

For this input :

 perl my_program 16.81 16.57 0 0

It gives me this result :

 16.57 = 0.985722784057109 * 16.81 + 0

Clearly b can be 0 only if the slope is 1. I don't know the reason for
this result (I guess precission but that's the only thing I could
say), neither how to solve it.
Please what should I do to get the correct result?

Thank you

camotito


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


Reply via email to