2.8) More On The Equal Sign
As an example of a statement that makes sense in programming but is nonsense in math, consider.
A=10.0 A=A+1.0
In programming, when the computer comes to this bit of the program it will first use the value of 10.0
to assign it to A
. On the next line it works out the RHS first so that A=10.0 is added to 1.0 to become 11.0 and it will be assigned to the LHS variable A. So now A=11.0.
In mathematics, the second equation
isn’t satisfied by A=10. This is why you must view the =
sign as an assignment operator.
Finally, on the LHS you must only have a single variable (not a number and not a formula). A+1.0=A makes no sense in programming since the value on the right cannot be assigned to the LHS since it is a calculation on the LHS. Likewise, 10=A makes no sense in programming because the RHS cannot be assigned to the LHS.