Knowledge

Relational operator

Source 📝

39: 448:
to each other by some set of language-specific rules, making the number 4 compare equal to the text string "4", for instance. Although such behaviour is typically meant to make the language easier, it can lead to surprising and difficult to predict consequences that many programmers are unaware of.
411:
Other programming elements such as computable functions, may either have no sense of equality, or an equality that is uncomputable. For these reasons, some languages define an explicit notion of "comparable", in the form of a base class, an interface, a trait or a protocol, which is used either
2291:(GCC), provide a warning when compiling code containing an assignment operator inside an if statement, though there are some legitimate uses of an assignment inside an if-condition. In such cases, the assignment must be wrapped in an extra pair of parentheses explicitly, to avoid the warning. 2094:
As a small type system was later introduced, B then became C. The popularity of this language along with its association with Unix, led to Java, C#, and many other languages following suit, syntactically, despite this needless conflict with the mathematical meaning of the equal sign.
338:
Structural equality (that is, their contents are the same). which may be either shallow (testing only immediate subparts), or deep (testing for equality of subparts recursively). A simple way to achieve this is through representational equality: checking that the values have the same
342:
Some other tailor-made equality, preserving the external behavior. For example, 1/2 and 2/4 are considered equal when seen as a rational number. A possible requirement would be that "A = B if and only if all operations on objects A and B will have the same result", in addition to
327:
Location equality (identity): if two references (A and B) reference the same object. Interactions with the object through A are indistinguishable from the same interactions through B, and in particular changes to the object through A are reflected through
2347:
is used accidentally, the resulting code is invalid because 2 is not a variable. The compiler will generate an error message, on which the proper operator can be substituted. This coding style is termed left-hand comparison, or
663: 1855:
does not do that since it maintains some compatibility with C, and "Allowing C expressions but with subtly different semantics (albeit arguably in the right direction) would add more confusion than convenience".
273:
can be used interchangeably in any context without noticing any difference". But this statement does not necessarily hold, particularly when taking into account mutability together with content equality.
1736:, if supported by the programming language, which means that they appear between their operands (the two expressions being related). For example, an expression in Python will print the message if the 545:
a comparison operator – that is, assigning a programmer-defined meaning that depends on the data types being compared. Another alternative is using some convention such as member-wise comparison.
257:
There can be multiple valid definitions of equality, and any particular language might adopt one or more of them, depending on various design aspects. One possible meaning of equality is that "if
388:, and it may be necessary to test for equality within a given tolerance. Such tolerance, however, can easily break desired properties such as transitivity, whereas reflexivity breaks too: the 2083:
or similar) and were allowed in expressions, this non standard meaning of the equal sign meant that the traditional semantics of the equal sign now had to be associated with another symbol.
1824:
However, many recent programming languages would see an expression like 3 < x < y as consisting of two left (or right-) associative operators, interpreting it as something like
2840: 3155:
has suggested that this may have had to do with "economy of typing" as updates of variables may be more frequent than comparisons in certain types of programs
3164:
A zero scalar value is interpreted as false while any non-zero scalar value is interpreted as true; this is typically used with integer types, similar to
582: 1851:
do that. Others, such as C# and Java, do not, partly because it would differ from the way most other infix operators work in C-like languages. The
2864:
to mean "b is a member of the set a", though the details of what it means to be a member vary considerably depending on the data types involved.
464:
A strict equality operator is also often available in those languages, returning true only for values with identical or equivalent types (in PHP,
535:(data types for which the programming language has no in-built understanding) may be carried out by custom-written or library functions (such as 2248:
have the same operators as C, this mistake usually causes a compile error in these languages instead, because the if-condition must be of type
564:, such that they can all be defined in terms of one another. The following four conditional statements all have the same logical equivalence 2024:
This uniform de facto standard among most programming languages was eventually changed, indirectly, by a minimalist compiled language named
373:
objects may be distinct objects (unequal in the first sense) but contain the same sequence of characters (equal in the second sense). See
1876: 3138:
As some programmers were confused by the dual meanings (bitwise operator, and logical connective) of these new symbols (according to
2306:
equality, as they are syntactically separate (as with Pascal, Ada, Python, etc., assignment operators cannot appear in expressions).
291: 1684:
in Macsyma/Maxima. Common Lisp has multiple other sets of equality and relational operators serving different purposes, including
103: 1836:
which generally does not make sense. However, it does compile in C/C++ and some other languages, yielding surprising result (as
75: 374: 246:
Equality is used in many programming language constructs and data types. It is used to test if an element already exists in a
3114: 82: 56: 1813:
In mathematics, it is common practice to chain relational operators, such as in 3 < x < y < 20 (meaning 3 < x
528:, the efficiency of comparison code is critical since it is one of the major factors contributing to sorting performance. 1732:
Relational operators are also used in technical literature instead of words. Relational operators are usually written in
3210: 3064: 2887: 122: 89: 510:, the usual convention is to assign −1 if a < b, 0 if a = b and 1 if a > b. For example, the C function 214:, relational operators return the integers 0 or 1, where 0 stands for false and any non-zero value stands for true. 3200: 206:, these operators usually evaluate to true or false, depending on if the conditional relationship between the two 2917: 71: 2578:
when a and b are two string objects containing equivalent characters, the === operator will still return true.
2445: 2309:
Some programmers get in the habit of writing comparisons against a constant in the reverse of the usual order:
2245: 1543: 1304: 230: 60: 2836: 2719: 2681: 2606: 2502: 2276: 2005: 2001: 1993: 1969: 1567: 1502: 1103: 955: 254:
to dispatch the control flow to the correct branch, and during the unification process in logic programming.
195: 502:
When it is desired to associate a numeric value with the result of a comparison between two data items, say
2738: 2009: 320: 2700: 2544: 2241: 1848: 1779: 1705: 1571: 1551: 404:
arithmetic (posit proponents mean to replace IEEE floats) has a similar concept, NaR (Not a Real), where
283: 203: 2355:
This table lists the different mechanisms to test for these two types of equality in various languages:
3205: 2272: 2044: 1981: 1945: 1066: 910: 680:
The most common numerical relational operators used in programming languages are shown below. Standard
495:
comparison of non-numeric data is performed according to a sort convention (such as, for text strings,
199: 2522: 2112: 2079:
in B. The reason for all this being unknown. As variable updates had no special syntax in B (such as
1547: 951: 385: 370: 331:
Content equality: if the objects referenced by two references (A and B) are equivalent in some sense:
3030: 597: 2984: 2882: 2413: 2280: 2033: 2025: 1575: 1535: 992: 704:
has it, but otherwise it has these same two operators defined as aliases, like many SQL databases.
697: 218: 211: 172: 412:
explicitly, by declaration in source code, or implicitly, via the structure of the type involved.
2907: 2288: 1612: 96: 49: 1821:
y < 20). The syntax is clear since these relational operators in mathematics are transitive.
2912: 2892: 1852: 1152: 381: 369:) which are unequal to themselves), but the converse is not necessarily true. For example, two 299: 295: 247: 160: 152: 148: 3016: 3044: 2028:. Its sole intended application was as a vehicle for a first port of (a then very primitive) 1459: 496: 401: 312:
two objects being equal but having different representation, e.g., a $ 1 bill and a $ 1 coin
2471: 1510: 541: 517: 144: 449:
For example, Javascript's loose equality rules can cause equality to be intransitive (ie.
8: 2104: 561: 352: 2980: 2279:, and many functional languages, among others, assignment operators cannot appear in an 499:) which may be built into the programming language and/or configurable by a programmer. 2922: 1600: 1433: 397: 344: 323:. In such languages, there becomes a need to test for two different types of equality: 319:
In many modern programming languages, objects and data structures are accessed through
2271:
In ALGOL-like languages such as Pascal, Delphi, and Ada (in the sense that they allow
480:
would be true for x being either 0 or "0" using the type agnostic equality operator).
3165: 3110: 3004: 2758: 2039:
B started off as a syntactically changed variant of the systems programming language
1847:
its familiar mathematical meaning, and some programming languages such as Python and
1673: 1592: 1155: 525: 187: 315:
two different references to the same object, e.g., two nicknames for the same person
2927: 2902: 1637: 557: 251: 136: 2959: 524:
expects the comparison function to return values according to this convention. In
2946: 2877: 2349: 1783: 693: 433: 156: 20: 19:"Comparison (computer programming)" redirects here. For comparison of files, see 1921:
character for copying, despite the obvious incoherence with mathematical usage (
3152: 3139: 2136: 1881:
Early FORTRAN (1956–57) was bounded by heavily restricted character sets where
1733: 1676:
use Basic-like operators for numerical values, except for inequality, which is
3080: 658:{\displaystyle E={\begin{cases}x<y\\y>x\\x\ngeq y\\y\nleq x\end{cases}}} 361:
The first type of equality usually implies the second (except for things like
3194: 1997: 554: 27: 2084: 1628:
MATLAB, although in other respects using similar syntax as C, does not use
1588: 669: 444:
even if two values are not equal and are of incompatible types, but can be
2135:
is not zero, execute the following statement". The latter fragment means "
3068: 2897: 2790: 2786: 2483: 1985: 1860: 1665: 1341: 191: 2563: 2287:
clauses), thus precluding this class of error. Some compilers, such as
1555: 1300: 1194: 421: 2868:
is here known as the "case equality" or "case subsumption" operator.
2850: 2587: 1973: 1641: 1596: 1467: 532: 287: 3129:
Used not only in ALGOL-like languages, but also in FORTRAN and BASIC
560:
XOR, AND, OR, and NOT, relational operators can be designed to have
38: 2375: 1977: 1953: 1929: 1498: 1437:
regimes are used in code on platforms with limited character sets (
1428: 812: 429: 389: 348: 3177: 476:, this operator may simplify things such as checking for zero (as 2794: 1949: 1669: 775: 472:
is true). For languages where the number 0 may be interpreted as
207: 1615:, so other symbols must be used. Without the hyphen, is used in 520:
and returns −1, 0, or 1 according to this convention, and
2335:/* Mistaken use of = versus == would be a compile-time error */ 1961: 1877:
Assignment (computer science) § Assignment versus equality
1494: 1231: 512: 229:. Relational operators can be seen as special cases of logical 309:
two objects being equal but distinct, e.g., two $ 10 banknotes
2583: 2417: 2295: 1989: 1933: 1539: 1490: 1029: 947: 684:
uses the same operators as BASIC, while many databases allow
521: 2252:, and there is no implicit way to convert from other types ( 2047:. In what has been described as a "strip-down" process, the 1917:
etc. and subsequently made it tempting to use the remaining
1636:
in MATLAB sends the following text as a command line to the
436:
languages, the standard equality operator follows so-called
2625: 2040: 2029: 2013: 1965: 1957: 1616: 1559: 651: 221:
created using a relational operator forms what is termed a
1885:
was the only relational operator available. There were no
461:), or make certain values be equal to their own negation. 2653: 2202:/* This code will always execute if y is anything but 0*/ 1563: 1506: 701: 681: 425: 366: 277: 2260:
s. So unless the variable that is assigned to has type
2071:, respectively.). In the same process, the ALGOL style 1901:). This forced the designers to define symbols such as 306:
two different objects of the same type, e.g., two hands
250:, or to access to a value through a key. It is used in 2107:
and since any non-zero scalar value is interpreted as
1870: 415: 3142:). Only the bitwise meaning of & and | were kept. 3081:"Why are there so many ways to compare for equality?" 1863:, use multiple argument predicates for this. In Lisp 585: 26:"~=" redirects here. For the mathematical usage, see 63:. Unsourced material may be challenged and removed. 657: 1944:available for equality, a convention followed by 186:In programming languages that include a distinct 3192: 2853:. This patent was granted on November 18, 2004. 2119:is legal, but has a very different meaning from 2032:, but it also evolved into the very influential 700:, which is common to most languages below. E.g. 675: 302:. It is often necessary to distinguish between: 2817:are pointers to objects that are instances of 568:(either all true or all false) for any given 3178:Brian Kernighan and Dennis Ritchie (1988) . 3104: 1840:would be represented by the number 1 here). 1770:"x is less than y in this example" 553:Though perhaps unobvious at first, like the 539:mentioned above), or, in some languages, by 1644:, with the exception of equality, which is 1657:Including FORTRAN 95, 2003, 2008 and 2015. 2123:. The former code fragment means "assign 2043:, a simplified (and typeless) version of 1419:Including FORTRAN II, III, IV, 66 and 77. 123:Learn how and when to remove this message 2979: 2933: 2012:, VHSIC Hardware Description Language ( 1956:, Basic Combined Programming Language ( 1928:International Algebraic Language (IAL, 3193: 1843:It is possible to give the expression 692:from the standard. SQL follows strict 548: 278:Location equality vs. content equality 3171: 2834:Patent application: On May 14, 2003, 2055:operators of BCPL were replaced with 1940:for assignment, leaving the standard 1778:Other programming languages, such as 286:, the comparison raises questions of 3045:"PHP: Comparison Operators - Manual" 2947:Standard for Posit Arithmetic (2022) 2845:"IS NOT OPERATOR" was filed for the 2146:, execute the following statement". 1867:is true when x is between 1 and 10. 1808: 380:Real numbers, including many simple 61:adding citations to reliable sources 32: 2294:Similarly, some languages, such as 1871:Confusion with assignment operators 1664:Other conventions are less common: 416:Comparing values of different types 384:, cannot be represented exactly in 210:holds or not. In languages such as 151:that tests or defines some kind of 13: 3037: 2888:Conditional (computer programming) 2268:), there will be a compile error. 1828:. If we say that x=4, we then get 14: 3222: 3182:(Second ed.). Prentice Hall. 2957: 2837:US application 20,040,230,959 1640:. The first form is also used in 531:Comparison of programmer-defined 3065:Relational and Logical Operators 2016:), and several other languages. 1936:(1958 and 1960) thus introduced 1611:are usually used in a shell for 668:This relies on the domain being 37: 3158: 3145: 3132: 3123: 3098: 3073: 3058: 2918:Operator (computer programming) 2828: 1651: 1622: 1581: 396:holds. In contrast, the (2022) 48:needs additional citations for 3109:. Addison Wesley. p. 58. 2973: 2951: 2940: 1528: 1516: 1483: 1422: 1413: 16:Programming language construct 1: 3105:Alexandrescu, Andrei (2010). 2753:when a and b have class type 1724:for the remaining operators. 1562:(numerical comparison only), 676:Standard relational operators 2768:object.ReferenceEquals(a, b) 2452:object.ReferenceEquals(a, b) 2098: 708:Common relational operators 7: 2871: 2302:symbol for both assignment 2273:nested function definitions 1832:, and evaluation will give 483: 284:object-oriented programming 282:Sometimes, particularly in 236: 10: 3227: 3180:The C Programming Language 3107:The D Programming Language 2648:are references to scalars 2539:when a and b are pointers 2131:, and if the new value of 2063:(which would later become 2019: 1874: 1466:), or platforms with only 440:, that is it evaluates to 159:. These include numerical 25: 18: 3211:Comparison (mathematical) 2849:operator by employees of 2835: 2534:reflect.DeepEqual(*a, *b) 2517:when a and b are numbers 2211:"x is %d and y is %d 1727: 1720:; and negated them using 1522:Modula-2 also recognizes 1340: 1230: 1132: 1127: 1122: 1117: 1102: 831: 826: 816: 811: 386:floating-point arithmetic 2883:Common operator notation 2311: 2148: 2103:Assignments in C have a 2075:of BCPL was replaced by 1788: 1746: 698:short-circuit evaluation 377:for more of this issue. 241: 3201:Operators (programming) 2908:Operation (mathematics) 2289:GNU Compiler Collection 2113:conditional expressions 1925:should be impossible). 392:standard requires that 2913:Operator (mathematics) 2893:Equality (mathematics) 2091:combination for this. 1853:D programming language 1619:for string comparison. 659: 2466:operator defaults to 1859:Some languages, like 1453:), platforms with no 660: 497:lexicographical order 223:relational expression 72:"Relational operator" 2934:Notes and references 1511:spreadsheet formulas 583: 518:three-way comparison 145:programming language 57:improve this article 2985:"Comparing Objects" 2367:Structural equality 1680:in Common Lisp and 709: 696:, i.e. doesn't use 562:logical equivalence 549:Logical equivalence 390:IEEE floating-point 141:relational operator 3015:has generic name ( 2923:Spaceship operator 1893:(and certainly no 1601:Windows PowerShell 707: 655: 650: 526:sorting algorithms 468:is false although 3206:Binary operations 3166:assembly language 3116:978-0-321-63536-5 3023:External link in 2824: 2823: 2759:Visual Basic .NET 2364:Physical equality 2264:(or wrapper type 1830:(3 < 4) < y 1826:(3 < x) < y 1809:Operator chaining 1409: 1408: 558:logical operators 434:dynamically typed 252:switch statements 188:boolean data type 133: 132: 125: 107: 3218: 3185: 3183: 3175: 3169: 3162: 3156: 3149: 3143: 3136: 3130: 3127: 3121: 3120: 3102: 3096: 3095: 3093: 3091: 3077: 3071: 3062: 3056: 3055: 3053: 3051: 3041: 3035: 3034: 3028: 3027: 3020: 3014: 3010: 3008: 3000: 2998: 2996: 2977: 2971: 2970: 2968: 2966: 2955: 2949: 2944: 2928:Triadic relation 2903:Logical operator 2867: 2863: 2854: 2848: 2844: 2843: 2839: 2832: 2820: 2816: 2812: 2806: 2802: 2778: 2774: 2769: 2765: 2750: 2745: 2731: 2726: 2712: 2707: 2693: 2688: 2675: 2671: 2665: 2660: 2647: 2643: 2637: 2632: 2618: 2613: 2599: 2594: 2575: 2570: 2556: 2551: 2536: 2535: 2529: 2514: 2509: 2495: 2490: 2477: 2469: 2465: 2459: 2454: 2453: 2439: 2435: 2429: 2424: 2407: 2403: 2397: 2392: 2382: 2358: 2357: 2346: 2339: 2336: 2333: 2330: 2327: 2324: 2321: 2318: 2315: 2301: 2286: 2267: 2263: 2259: 2256:, numbers) into 2251: 2236: 2233: 2230: 2227: 2224: 2221: 2218: 2215: 2212: 2209: 2206: 2203: 2200: 2197: 2194: 2191: 2188: 2185: 2182: 2179: 2176: 2173: 2170: 2167: 2164: 2161: 2158: 2155: 2152: 2122: 2118: 2090: 2087:used the ad hoc 2082: 2078: 2074: 2070: 2066: 2062: 2058: 2054: 2050: 1964:, SET Language ( 1943: 1939: 1924: 1920: 1916: 1912: 1908: 1904: 1900: 1896: 1892: 1888: 1884: 1866: 1846: 1835: 1831: 1827: 1804: 1801: 1798: 1795: 1792: 1774: 1771: 1768: 1765: 1762: 1759: 1756: 1753: 1750: 1723: 1719: 1715: 1711: 1703: 1699: 1695: 1691: 1687: 1683: 1679: 1658: 1655: 1649: 1647: 1638:operating system 1635: 1631: 1626: 1620: 1610: 1606: 1585: 1579: 1532: 1526: 1525: 1520: 1514: 1487: 1481: 1479: 1473: 1465: 1458: 1452: 1448: 1444: 1426: 1420: 1417: 1405: 1400: 1395: 1390: 1385: 1380: 1373: 1368: 1363: 1358: 1353: 1348: 1336: 1331: 1326: 1321: 1316: 1311: 1295: 1290: 1285: 1280: 1275: 1270: 1263: 1258: 1253: 1248: 1243: 1238: 1226: 1221: 1216: 1211: 1206: 1201: 1189: 1184: 1179: 1174: 1167: 1162: 1147: 1142: 1135: 1130: 1125: 1120: 1115: 1110: 1098: 1093: 1088: 1083: 1078: 1073: 1061: 1056: 1051: 1046: 1041: 1036: 1024: 1019: 1014: 1009: 1004: 999: 987: 982: 977: 972: 967: 962: 942: 937: 932: 927: 922: 917: 905: 898: 891: 884: 877: 870: 861: 856: 851: 844: 839: 834: 829: 824: 819: 807: 802: 797: 792: 787: 782: 710: 706: 691: 687: 664: 662: 661: 656: 654: 653: 538: 515: 479: 471: 467: 460: 456: 452: 432:and a few other 398:private standard 182: 170: 137:computer science 128: 121: 117: 114: 108: 106: 65: 41: 33: 3226: 3225: 3221: 3220: 3219: 3217: 3216: 3215: 3191: 3190: 3189: 3188: 3176: 3172: 3163: 3159: 3150: 3146: 3137: 3133: 3128: 3124: 3117: 3103: 3099: 3089: 3087: 3079: 3078: 3074: 3063: 3059: 3049: 3047: 3043: 3042: 3038: 3025: 3024: 3022: 3012: 3011: 3002: 3001: 2994: 2992: 2978: 2974: 2964: 2962: 2958:Denys, Dovhan. 2956: 2952: 2945: 2941: 2936: 2878:Binary relation 2874: 2865: 2861: 2858: 2857: 2846: 2841: 2833: 2829: 2818: 2814: 2810: 2805: 2800: 2776: 2772: 2767: 2763: 2748: 2743: 2729: 2724: 2710: 2705: 2691: 2686: 2673: 2669: 2663: 2658: 2645: 2641: 2635: 2630: 2616: 2611: 2597: 2592: 2573: 2568: 2554: 2549: 2533: 2532: 2527: 2512: 2507: 2493: 2488: 2475: 2468:ReferenceEquals 2467: 2463: 2457: 2451: 2450: 2437: 2433: 2427: 2422: 2405: 2401: 2395: 2386: 2380: 2350:Yoda conditions 2344: 2341: 2340: 2337: 2334: 2331: 2328: 2325: 2322: 2319: 2316: 2313: 2299: 2284: 2265: 2261: 2257: 2249: 2238: 2237: 2234: 2231: 2228: 2225: 2222: 2219: 2216: 2213: 2210: 2207: 2204: 2201: 2198: 2195: 2192: 2189: 2186: 2183: 2180: 2177: 2174: 2171: 2168: 2165: 2162: 2159: 2156: 2153: 2150: 2120: 2116: 2101: 2088: 2080: 2076: 2072: 2068: 2064: 2060: 2056: 2052: 2048: 2022: 1941: 1937: 1922: 1918: 1914: 1910: 1906: 1902: 1898: 1894: 1890: 1886: 1882: 1879: 1873: 1864: 1845:x < y < z 1844: 1833: 1829: 1825: 1811: 1806: 1805: 1802: 1799: 1796: 1793: 1790: 1784:prefix notation 1776: 1775: 1772: 1769: 1766: 1763: 1760: 1757: 1754: 1751: 1748: 1730: 1721: 1717: 1713: 1709: 1701: 1697: 1693: 1689: 1685: 1681: 1677: 1662: 1661: 1656: 1652: 1645: 1633: 1629: 1627: 1623: 1608: 1604: 1586: 1582: 1533: 1529: 1523: 1521: 1517: 1488: 1484: 1477: 1471: 1463: 1454: 1450: 1446: 1442: 1427: 1423: 1418: 1414: 1403: 1398: 1393: 1388: 1383: 1378: 1371: 1366: 1361: 1356: 1351: 1346: 1334: 1329: 1324: 1319: 1314: 1309: 1293: 1288: 1283: 1278: 1273: 1268: 1261: 1256: 1251: 1246: 1241: 1236: 1224: 1219: 1214: 1209: 1204: 1199: 1187: 1182: 1177: 1170: 1165: 1160: 1145: 1140: 1133: 1128: 1123: 1118: 1113: 1108: 1096: 1091: 1086: 1081: 1076: 1071: 1059: 1054: 1049: 1044: 1039: 1034: 1022: 1017: 1012: 1007: 1002: 997: 985: 980: 975: 970: 965: 960: 940: 935: 930: 925: 920: 915: 901: 894: 887: 880: 873: 866: 859: 854: 849: 842: 837: 832: 827: 822: 817: 805: 800: 795: 790: 785: 780: 745: 738: 694:boolean algebra 689: 688:in addition to 685: 678: 649: 648: 636: 635: 623: 622: 610: 609: 593: 592: 584: 581: 580: 551: 536: 511: 486: 477: 469: 465: 458: 454: 450: 418: 339:representation. 280: 244: 239: 180: 168: 129: 118: 112: 109: 66: 64: 54: 42: 31: 24: 21:File comparison 17: 12: 11: 5: 3224: 3214: 3213: 3208: 3203: 3187: 3186: 3170: 3157: 3153:Dennis Ritchie 3144: 3140:Dennis Ritchie 3131: 3122: 3115: 3097: 3085:Stack Overflow 3072: 3057: 3036: 2972: 2950: 2938: 2937: 2935: 2932: 2931: 2930: 2925: 2920: 2915: 2910: 2905: 2900: 2895: 2890: 2885: 2880: 2873: 2870: 2856: 2855: 2826: 2825: 2822: 2821: 2807: 2803: 2798: 2783: 2782: 2779: 2770: 2761: 2755: 2754: 2751: 2746: 2741: 2735: 2734: 2732: 2727: 2722: 2716: 2715: 2713: 2708: 2703: 2697: 2696: 2694: 2689: 2684: 2678: 2677: 2666: 2661: 2656: 2650: 2649: 2638: 2636:$ $ a == $ $ b 2633: 2628: 2622: 2621: 2619: 2614: 2609: 2603: 2602: 2600: 2595: 2590: 2580: 2579: 2576: 2571: 2566: 2560: 2559: 2557: 2552: 2547: 2541: 2540: 2537: 2530: 2525: 2519: 2518: 2515: 2510: 2505: 2499: 2498: 2496: 2491: 2486: 2480: 2479: 2460: 2455: 2448: 2442: 2441: 2430: 2425: 2420: 2410: 2409: 2398: 2393: 2378: 2372: 2371: 2368: 2365: 2362: 2312: 2149: 2137:if and only if 2100: 2097: 2021: 2018: 1872: 1869: 1865:(<= 1 x 10) 1810: 1807: 1789: 1786:, as follows: 1747: 1734:infix notation 1729: 1726: 1660: 1659: 1650: 1621: 1603:. The symbols 1580: 1527: 1515: 1482: 1421: 1411: 1410: 1407: 1406: 1401: 1396: 1391: 1386: 1381: 1375: 1374: 1369: 1364: 1359: 1354: 1349: 1344: 1338: 1337: 1332: 1327: 1322: 1317: 1312: 1307: 1297: 1296: 1291: 1286: 1281: 1276: 1271: 1265: 1264: 1259: 1254: 1249: 1244: 1239: 1234: 1228: 1227: 1222: 1217: 1212: 1207: 1202: 1197: 1191: 1190: 1185: 1180: 1175: 1168: 1163: 1158: 1149: 1148: 1143: 1137: 1136: 1131: 1126: 1121: 1116: 1111: 1106: 1100: 1099: 1094: 1089: 1084: 1079: 1074: 1069: 1063: 1062: 1057: 1052: 1047: 1042: 1037: 1032: 1026: 1025: 1020: 1015: 1010: 1005: 1000: 995: 989: 988: 983: 978: 973: 968: 963: 958: 944: 943: 938: 933: 928: 923: 918: 913: 907: 906: 899: 892: 885: 878: 871: 863: 862: 857: 852: 846: 845: 840: 835: 830: 825: 820: 815: 809: 808: 803: 798: 793: 788: 783: 778: 772: 771: 768: 765: 762: 759: 756: 753: 749: 748: 741: 734: 729: 724: 719: 714: 677: 674: 666: 665: 652: 647: 644: 641: 638: 637: 634: 631: 628: 625: 624: 621: 618: 615: 612: 611: 608: 605: 602: 599: 598: 596: 591: 588: 550: 547: 485: 482: 417: 414: 359: 358: 357: 356: 340: 333: 332: 329: 317: 316: 313: 310: 307: 279: 276: 265:, then either 243: 240: 238: 235: 131: 130: 45: 43: 36: 15: 9: 6: 4: 3: 2: 3223: 3212: 3209: 3207: 3204: 3202: 3199: 3198: 3196: 3181: 3174: 3167: 3161: 3154: 3148: 3141: 3135: 3126: 3118: 3112: 3108: 3101: 3086: 3082: 3076: 3070: 3066: 3061: 3046: 3040: 3032: 3026:|author= 3018: 3013:|author= 3006: 2990: 2986: 2982: 2976: 2961: 2954: 2948: 2943: 2939: 2929: 2926: 2924: 2921: 2919: 2916: 2914: 2911: 2909: 2906: 2904: 2901: 2899: 2896: 2894: 2891: 2889: 2886: 2884: 2881: 2879: 2876: 2875: 2869: 2852: 2838: 2831: 2827: 2808: 2804: 2799: 2796: 2792: 2788: 2785: 2784: 2780: 2771: 2762: 2760: 2757: 2756: 2752: 2747: 2742: 2740: 2737: 2736: 2733: 2728: 2723: 2721: 2718: 2717: 2714: 2709: 2704: 2702: 2699: 2698: 2695: 2690: 2685: 2683: 2680: 2679: 2667: 2662: 2657: 2655: 2652: 2651: 2639: 2634: 2629: 2627: 2624: 2623: 2620: 2615: 2610: 2608: 2605: 2604: 2601: 2596: 2591: 2589: 2585: 2582: 2581: 2577: 2572: 2567: 2565: 2562: 2561: 2558: 2553: 2548: 2546: 2543: 2542: 2538: 2531: 2526: 2524: 2521: 2520: 2516: 2511: 2506: 2504: 2501: 2500: 2497: 2492: 2487: 2485: 2482: 2481: 2473: 2470:, but can be 2461: 2456: 2449: 2447: 2444: 2443: 2440:are pointers 2431: 2426: 2421: 2419: 2415: 2412: 2411: 2408:are pointers 2399: 2394: 2390: 2385: 2379: 2377: 2374: 2373: 2369: 2366: 2363: 2360: 2359: 2356: 2353: 2351: 2310: 2307: 2305: 2298:use just the 2297: 2292: 2290: 2282: 2278: 2274: 2269: 2255: 2247: 2243: 2147: 2145: 2141: 2138: 2134: 2130: 2126: 2114: 2110: 2106: 2096: 2092: 2086: 2046: 2042: 2037: 2035: 2031: 2027: 2017: 2015: 2011: 2007: 2003: 1999: 1998:Object Pascal 1995: 1991: 1987: 1983: 1979: 1975: 1971: 1967: 1963: 1959: 1955: 1951: 1947: 1935: 1931: 1926: 1878: 1868: 1862: 1857: 1854: 1850: 1841: 1839: 1822: 1820: 1816: 1787: 1785: 1781: 1745: 1743: 1740:is less than 1739: 1735: 1725: 1707: 1675: 1671: 1667: 1654: 1643: 1639: 1625: 1618: 1614: 1602: 1598: 1594: 1590: 1584: 1577: 1573: 1569: 1565: 1561: 1557: 1553: 1549: 1545: 1541: 1537: 1531: 1519: 1513:, and others. 1512: 1508: 1504: 1500: 1496: 1492: 1486: 1476: 1469: 1461: 1457: 1440: 1436: 1435: 1430: 1425: 1416: 1412: 1402: 1397: 1392: 1387: 1382: 1377: 1376: 1370: 1365: 1360: 1355: 1350: 1345: 1343: 1339: 1333: 1328: 1323: 1318: 1313: 1308: 1306: 1302: 1299: 1298: 1292: 1287: 1282: 1277: 1272: 1267: 1266: 1260: 1255: 1250: 1245: 1240: 1235: 1233: 1229: 1223: 1218: 1213: 1208: 1203: 1198: 1196: 1193: 1192: 1186: 1181: 1176: 1173: 1169: 1164: 1159: 1157: 1154: 1151: 1150: 1144: 1139: 1138: 1112: 1107: 1105: 1101: 1095: 1090: 1085: 1080: 1075: 1070: 1068: 1065: 1064: 1058: 1053: 1048: 1043: 1038: 1033: 1031: 1028: 1027: 1021: 1016: 1011: 1006: 1001: 996: 994: 991: 990: 984: 979: 974: 969: 964: 959: 957: 953: 949: 946: 945: 939: 934: 929: 924: 919: 914: 912: 909: 908: 904: 900: 897: 893: 890: 886: 883: 879: 876: 872: 869: 865: 864: 858: 853: 848: 847: 841: 836: 821: 814: 810: 804: 799: 794: 789: 784: 779: 777: 774: 773: 769: 766: 763: 760: 757: 754: 751: 750: 747: 742: 740: 735: 733: 730: 728: 725: 723: 720: 718: 715: 712: 711: 705: 703: 699: 695: 683: 673: 671: 645: 642: 639: 632: 629: 626: 619: 616: 613: 606: 603: 600: 594: 589: 586: 579: 578: 577: 575: 571: 567: 563: 559: 556: 546: 544: 543: 534: 529: 527: 523: 519: 514: 509: 505: 500: 498: 494: 490: 481: 475: 462: 447: 443: 439: 435: 431: 427: 423: 413: 409: 407: 403: 399: 395: 391: 387: 383: 378: 376: 372: 368: 364: 354: 350: 346: 341: 337: 336: 335: 334: 330: 326: 325: 324: 322: 314: 311: 308: 305: 304: 303: 301: 297: 293: 289: 285: 275: 272: 268: 264: 260: 255: 253: 249: 234: 232: 228: 224: 220: 215: 213: 209: 205: 201: 197: 193: 189: 184: 178: 174: 166: 162: 158: 154: 150: 147:construct or 146: 142: 138: 127: 124: 116: 105: 102: 98: 95: 91: 88: 84: 81: 77: 74: –  73: 69: 68:Find sources: 62: 58: 52: 51: 46:This article 44: 40: 35: 34: 29: 28:approximation 22: 3179: 3173: 3160: 3147: 3134: 3125: 3106: 3100: 3088:. Retrieved 3084: 3075: 3060: 3048:. Retrieved 3039: 2993:. Retrieved 2988: 2981:Contributors 2975: 2963:. Retrieved 2953: 2942: 2859: 2830: 2730:(equal? a b) 2676:are objects 2388: 2383: 2381:a :=: b 2354: 2342: 2308: 2303: 2293: 2270: 2253: 2239: 2143: 2142:is equal to 2139: 2132: 2128: 2124: 2108: 2102: 2093: 2085:Ken Thompson 2038: 2023: 1927: 1880: 1858: 1842: 1837: 1823: 1818: 1814: 1812: 1777: 1741: 1737: 1731: 1663: 1653: 1624: 1589:Bourne shell 1583: 1530: 1518: 1485: 1474: 1455: 1438: 1432: 1424: 1415: 1399:GreaterEqual 1171: 902: 895: 888: 881: 874: 867: 743: 737:greater than 736: 731: 727:greater than 726: 722:not equal to 721: 716: 679: 670:well ordered 667: 573: 569: 565: 552: 540: 530: 507: 503: 501: 492: 489:Greater than 488: 487: 473: 463: 445: 441: 438:loose typing 437: 419: 410: 405: 393: 379: 363:not a number 362: 360: 353:transitivity 318: 281: 270: 266: 262: 258: 256: 245: 226: 222: 216: 185: 176: 173:inequalities 164: 157:two entities 140: 134: 119: 110: 100: 93: 86: 79: 67: 55:Please help 50:verification 47: 3069:Mathematica 2991:. PHP Group 2898:Equals sign 2787:Objective-C 2781:Same as C# 2777:a.Equals(b) 2706:a.equal?(b) 2659:$ a === $ b 2555:a.equals(b) 2494:(equal a b) 2484:Common Lisp 2474:to perform 2458:a.Equals(b) 2283:(including 2121:if (x == y) 2115:, the code 1986:Standard ML 1861:Common Lisp 1834:true < y 1666:Common Lisp 1613:redirection 1449:instead of 1342:Mathematica 1153:Bourne-like 746:or equal to 739:or equal to 713:Convention 542:overloading 516:performs a 459:a != c 345:reflexivity 292:inheritance 192:type system 3195:Categories 2989:PHP Manual 2860:Ruby uses 2664:$ a == $ b 2631:$ a == $ b 2564:JavaScript 2472:overloaded 2281:expression 2275:), and in 2117:if (x = y) 2065:&& 2036:language. 1875:See also: 1587:Including 1556:JavaScript 1534:Including 1489:Including 1301:Fortran 90 1195:Batch file 533:data types 422:JavaScript 321:references 288:data types 231:predicates 219:expression 113:March 2022 83:newspapers 3151:Although 2851:Microsoft 2725:(eq? a b) 2588:Smalltalk 2478:instead. 2099:Languages 1974:Smalltalk 1817:x < y 1642:Smalltalk 1597:KornShell 1468:UPPERCASE 1434:stropping 1404:LessEqual 752:In print 744:less than 732:less than 643:≰ 630:≱ 493:less than 466:4 === "4" 406:NaR = NaR 394:NaN ≠ NaN 382:fractions 227:condition 190:in their 3090:July 25, 3050:July 31, 3005:cite web 2995:June 29, 2965:July 25, 2872:See also 2819:NSObject 2489:(eq a b) 2428:*a == *b 2376:ALGOL 68 2361:Language 1978:Modula-2 1954:ALGOL 68 1930:ALGOL 58 1714:greaterp 1704:. Older 1499:Modula-2 1460:emphasis 1429:ALGOL 68 966:<> 813:ALGOL 68 717:equal to 690:<> 576:values: 484:Ordering 470:4 == "4" 430:VBScript 375:identity 349:symmetry 300:identity 296:equality 237:Equality 208:operands 161:equality 155:between 153:relation 149:operator 3168:idioms. 2960:"WTFJS" 2862:a === b 2795:GNUstep 2744:a === b 2612:a^ = b^ 2569:a === b 2508:a =:= b 2266:Boolean 2262:boolean 2258:boolean 2250:boolean 2240:Though 2020:B and C 1950:ALGOL W 1702:string= 1670:Macsyma 1389:Greater 1384:Unequal 1305:Haskell 1294:le(x,y) 1289:ge(x,y) 1284:lt(x,y) 1279:gt(x,y) 1274:ne(x,y) 1269:eq(x,y) 776:FORTRAN 555:boolean 446:coerced 408:holds. 261:equals 194:, like 97:scholar 3113:  2842:  2801:a == b 2764:a Is b 2749:a == b 2720:Scheme 2711:a == b 2692:a == b 2687:a is b 2682:Python 2607:Pascal 2593:a == b 2574:a == b 2550:a == b 2528:a == b 2513:a == b 2503:Erlang 2476:Equals 2423:a == b 2370:Notes 2277:Python 2217:" 2205:printf 2006:Oberon 2002:Delphi 1994:Eiffel 1970:Pascal 1962:Simula 1932:) and 1782:, use 1728:Syntax 1716:, and 1700:, and 1698:equalp 1674:Maxima 1599:, and 1574:, and 1568:Python 1503:Eiffel 1495:Simula 1441:, use 1232:MATLAB 1156:shells 1104:Erlang 993:C-like 956:Pascal 537:strcmp 513:strcmp 478:x == 0 457:, but 455:b == c 451:a == b 371:string 351:, and 298:, and 196:Pascal 171:) and 99:  92:  85:  78:  70:  2847:ISNOT 2809:when 2791:Cocoa 2773:a = b 2739:Swift 2668:when 2640:when 2617:a = b 2598:a = b 2584:OCaml 2432:when 2400:when 2396:a = b 2296:BASIC 2105:value 2057:& 2010:Dylan 1990:OCaml 1934:ALGOL 1923:X=X+1 1794:>= 1764:print 1718:lessp 1710:equal 1708:used 1706:Lisps 1694:equal 1632:, as 1491:ALGOL 1470:(use 1462:(use 1443:>= 1379:Equal 1372:<= 1367:>= 1335:<= 1330:>= 1262:<= 1257:>= 1134:=< 1129:>= 1097:<= 1092:>= 1060:'> 1055:'< 1030:MUMPS 1023:<= 1018:>= 986:<= 981:>= 948:BASIC 860:<= 855:>= 764:< 761:> 522:qsort 474:false 402:posit 242:Usage 225:or a 202:, or 181:4 ≥ 3 169:5 = 5 143:is a 104:JSTOR 90:books 3184:, 19 3111:ISBN 3092:2024 3052:2008 3031:help 3017:help 2997:2014 2967:2024 2813:and 2701:Ruby 2672:and 2644:and 2626:Perl 2545:Java 2462:The 2436:and 2404:and 2254:e.g. 2244:and 2242:Java 2109:true 2067:and 2059:and 2051:and 2041:BCPL 2030:Unix 2014:VHDL 1966:SETL 1958:BCPL 1915:.EQ. 1911:.GE. 1907:.LT. 1903:.GT. 1891:> 1887:< 1849:Raku 1838:true 1780:Lisp 1755:< 1668:and 1617:Perl 1609:> 1607:and 1605:< 1593:Bash 1572:Ruby 1560:Perl 1552:Java 1478:'GE' 1464:'ge' 1456:bold 1439:e.g. 1394:Less 1362:< 1357:> 1325:< 1320:> 1252:< 1247:> 1124:< 1119:> 1087:< 1082:> 1050:< 1045:> 1013:< 1008:> 976:< 971:> 931:< 926:> 833:< 828:> 806:.LE. 801:.GE. 796:.LT. 791:.GT. 786:.NE. 781:.EQ. 617:> 604:< 572:and 506:and 491:and 453:and 442:true 400:for 290:and 204:Java 177:e.g. 165:e.g. 139:, a 76:news 3067:of 2866:=== 2775:or 2766:or 2674:$ b 2670:$ a 2654:PHP 2646:$ b 2642:$ a 2418:C++ 2343:If 2304:and 2166:int 2151:int 2127:to 2111:in 2081:let 2049:and 2045:CPL 2004:), 1982:Ada 1968:), 1960:), 1946:CPL 1897:or 1889:or 1819:and 1815:and 1722:not 1690:eql 1564:PHP 1540:C++ 1507:SQL 1472:.GE 1445:or 1225:LEQ 1220:GEQ 1215:LSS 1210:GTR 1205:NEQ 1200:EQU 1188:-le 1183:-ge 1178:-lt 1172:-gt 1166:-ne 1161:-eq 1146:=/= 1141:=:= 1067:Lua 911:APL 702:PHP 682:SQL 426:PHP 420:In 367:NaN 269:or 248:set 217:An 200:Ada 183:). 135:In 59:by 3197:: 3083:. 3021:; 3009:: 3007:}} 3003:{{ 2987:. 2983:. 2793:, 2586:, 2523:Go 2464:== 2446:C# 2416:, 2389:is 2387:a 2384:or 2352:. 2323:== 2314:if 2285:if 2246:C# 2232:); 2214:\n 2181:if 2089:== 2073::= 2069:|| 2053:or 2008:, 1996:, 1992:, 1988:, 1984:, 1980:, 1976:, 1972:, 1952:, 1948:, 1938::= 1913:, 1909:, 1905:, 1749:if 1744:: 1712:, 1696:, 1692:, 1688:, 1686:eq 1678:/= 1630:!= 1595:, 1591:, 1570:, 1566:, 1558:, 1554:, 1550:, 1548:Go 1546:, 1544:C# 1542:, 1538:, 1509:, 1505:, 1501:, 1497:, 1493:, 1480:). 1475:or 1447:GE 1431:: 1352:!= 1347:== 1315:/= 1310:== 1303:, 1242:~= 1237:== 1114:/= 1109:== 1077:~= 1072:== 1040:'= 1003:!= 998:== 954:, 952:ML 950:, 903:le 896:ge 889:lt 882:gt 875:ne 868:eq 850:/= 770:≤ 767:≥ 758:≠ 755:= 686:!= 672:. 428:, 424:, 347:, 328:B. 294:, 233:. 198:, 179:, 167:, 3119:. 3094:. 3054:. 3033:) 3029:( 3019:) 2999:. 2969:. 2815:b 2811:a 2797:) 2789:( 2438:b 2434:a 2414:C 2406:b 2402:a 2391:b 2345:= 2338:} 2332:{ 2329:) 2326:a 2320:2 2317:( 2300:= 2235:} 2229:y 2226:, 2223:x 2220:, 2208:( 2199:{ 2196:) 2193:y 2190:= 2187:x 2184:( 2178:; 2175:2 2172:= 2169:y 2163:; 2160:1 2157:= 2154:x 2144:y 2140:x 2133:x 2129:x 2125:y 2077:= 2061:| 2034:C 2026:B 2000:( 1942:= 1919:= 1899:≥ 1895:≤ 1883:= 1803:) 1800:Y 1797:X 1791:( 1773:) 1767:( 1761:: 1758:y 1752:x 1742:y 1738:x 1682:# 1672:/ 1648:. 1646:= 1634:! 1578:. 1576:R 1536:C 1524:# 1451:≥ 1035:= 961:= 941:≤ 936:≥ 921:≠ 916:= 843:≤ 838:≥ 823:≠ 818:= 646:x 640:y 633:y 627:x 620:x 614:y 607:y 601:x 595:{ 590:= 587:E 574:y 570:x 566:E 508:b 504:a 365:( 355:. 271:b 267:a 263:b 259:a 212:C 175:( 163:( 126:) 120:( 115:) 111:( 101:· 94:· 87:· 80:· 53:. 30:. 23:.

Index

File comparison
approximation

verification
improve this article
adding citations to reliable sources
"Relational operator"
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
computer science
programming language
operator
relation
two entities
equality
inequalities
boolean data type
type system
Pascal
Ada
Java
operands
C
expression
predicates
set

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.