October 26, 2009

equality & assignment

The equals sign has two totally different meanings: equality and assignment.

In mathematics, x = y means that the quantity represented by x and the quantity represented by y have equal values.

In computer programming, x = y means that the present value of y should become the new value of x.

So, in math, x = x + 1 would be a contradiction,
while in software, x = x + 1 increments the value of x by one.

(I have heard computer science people refer to "=" as "the assignment operator" rather than as "the equals sign".)

No comments:

Post a Comment


Blog Archive