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 - $ARGV) / ($ARGV - $ARGV);
$b = $ARGV - ($ARGV * $slope);
print "\n$ARGV = $slope * $ARGV + $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?