/
html/
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.51
     from ProgrammersManual.texinfo on 4 March 1997 -->

<TITLE>LambdaMOO Programmer's Manual - Comparisons</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="ProgrammersManual_1.html">first</A>, <A HREF="ProgrammersManual_14.html">previous</A>, <A HREF="ProgrammersManual_16.html">next</A>, <A HREF="ProgrammersManual_77.html">last</A> section, <A HREF="ProgrammersManual_toc.html">table of contents</A>.
<P><HR><P>


<H3><A NAME="SEC15" HREF="ProgrammersManual_toc.html#TOC15">Comparing Values</A></H3>

<P>
Any two values can be compared for equality using <SAMP>`=='</SAMP> and
<SAMP>`!='</SAMP>.  The first of these returns 1 if the two values are equal and
0 otherwise; the second does the reverse:

</P>

<PRE>
3 == 4                              =>  0
3 != 4                              =>  1
3 == 3.0                            =>  0
"foo" == "Foo"                      =>  1
#34 != #34                          =>  0
{1, #34, "foo"} == {1, #34, "FoO"}  =>  1
E_DIV == E_TYPE                     =>  0
3 != "foo"                          =>  1
</PRE>

<P>
Note that integers and floating-point numbers are never equal to one another,
even in the `obvious' cases.  Also note that comparison of strings (and list
values containing strings) is case-insensitive; that is, it does not
distinguish between the upper- and lower-case version of letters.  To test two
values for case-sensitive equality, use the <SAMP>`equal'</SAMP> function described
later.

</P>

<BLOCKQUOTE>
<P>
<STRONG>Warning</STRONG>: It is easy (and very annoying) to confuse the
equality-testing operator (<SAMP>`=='</SAMP>) with the assignment operator (<SAMP>`='</SAMP>),
leading to nasty, hard-to-find bugs.  Don't do this.
</BLOCKQUOTE>

<P>
Numbers, object numbers, strings, and error values can also be compared
for ordering purposes using the following operators:

</P>

<PRE>
&#60;       &#60;=      &#62;=      &#62;
</PRE>

<P>
meaning "less than," "less than or equal," "greater than or
equal," and "greater than," respectively.  As with the equality
operators, these return 1 when their operands are in the appropriate
relation and 0 otherwise:

</P>

<PRE>
3 &#60; 4           =>  1
3 &#60; 4.0         error-->  E_TYPE
#34 &#62;= #32      =>  1
"foo" &#60;= "Boo"  =>  0
E_DIV &#62; E_TYPE  =>  1
</PRE>

<P>
Note that, as with the equality operators, strings are compared
case-insensitively.  To perform a case-sensitive string comparison, use the
<SAMP>`strcmp'</SAMP> function described later.  Also note that the error values are
ordered as given in the table in the section on values.  If the operands to
these four comparison operators are of different types (even integers and
floating-point numbers are considered different types), or if they are lists,
then <CODE>E_TYPE</CODE> is raised.

</P>
<P><HR><P>
Go to the <A HREF="ProgrammersManual_1.html">first</A>, <A HREF="ProgrammersManual_14.html">previous</A>, <A HREF="ProgrammersManual_16.html">next</A>, <A HREF="ProgrammersManual_77.html">last</A> section, <A HREF="ProgrammersManual_toc.html">table of contents</A>.
</BODY>
</HTML>