Tim923 wrote:
The following lines were tried:
x1 = (-b + sqrt(pow(b,2)-(4*a*c))) /(2*a);
x1 = (-b + sqrt(pow(b,2)-(4*a*c))) / 2*a;
I noticed that the last parentheses were optional and didn't change
anything.
Although if I mean 1/(2*5)=0.1 then 1/2*5=2.5 is not the same. What
is the difference?
It's not order, but grouping. That is, you have to be sure that each
operation gets applied to the correct operands. Generally speaking, math
operators group from left to right, so a/b*c says that a should be
divided by b, and the result multiplied by c. To change this grouping,
add parentheses: a/(b*c).
--
Pete Becker
Dinkumware, Ltd. (
http://www.dinkumware.com)