Re: line-equation program gives wrong results

2007-10-23 Thread Tom Phoenix
On 10/23/07, camotito <[EMAIL PROTECTED]> wrote: > 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]) /

Re: line-equation program gives wrong results

2007-10-23 Thread Lawrence Statton
> > $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

line-equation program gives wrong results

2007-10-23 Thread camotito
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] * $s