Equals (computing)

From Wikipedia, the free encyclopedia

Equals (=), in computing, is a symbol that is used in several programming languages.

Contents

[edit] Names

The equals sign is ASCII character 61, and has multiple names that are commonly used. These include "ITU-T", "equals", "gets", and "takes". Although less commonly used, "quadrathorpe", "INTERCAL", and "half-mesh" are acceptable.

[edit] Programming

The equal sign is used in many programming languages, such as BASIC and C as the assignment operator.

Other languages, such as Ada and Pascal, use variants such as := ("becomes equal to") to avoid upsetting mathematicians with statements such as "x = x+1" (and to avoid common typos in comparisons that can happen in languages that consider assignment to be an operator that may be used anywhere in an expression. e.g., the === confusion in C). In these languages the := is not considered an operator and may only occur between the variable and the expression of the assignment.

This sign is also used by itself, and in compounds such as <=, >=, ==, /=, != for various relational operators, and in C's +=, *= etc. which mimic the primitive operations of two-address code.

[edit] Operators

Many languages have different equality predicates, operators which test the equality of values. For instance, Perl has the numerical equality operator == and the string equality operator eq.

Equality is a property of values, not objects. An operator which asks if two variables refer to the same data object is an identity predicate, such as Python's is or Common Lisp's EQ.

[edit] See also