Access VBA:
=, <>
Save as VB Classic. Common comparison operators:
=
equal
<>
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
Syntax Example:
//Does Access evaluate the math correctly? No! If 0.1 + 0.1 + 0.1 = 0.3 Then MsgBox "correct" Else MsgBox "not correct" End If
ASP Classic:
=, <>
Save as VB Classic. Common comparison operators:
=
equal
<>
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
Syntax Example: //Does ASP evaluate the math correctly? No! If .1 + .1 + .1 = .3 Then Response.Write "correct" Else Response.Write "not correct" End If
C#:
==, !=
Common comparison operators:
==
equal
!=
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
Syntax Example:
//Does C# evaluate the math correctly? No! if (.1 + .1 + .1 == .3) MessageBox.Show("correct"); else MessageBox.Show("not correct");
C++:
==, !=
Common comparison operators:
==
equal
!=
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
Syntax Example:
//C++Builder example (ShowMessage is a VCL method). //Does C++Builder evaluate the math correctly? No! If (.1 + .1 + .1 == .3) ShowMessage("correct"); else ShowMessage("not correct");
C++/CLI:
==, !=
Same as standard C++. Common comparison operators:
==
equal
!=
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
Syntax Example:
//Does C++/CLI evaluate the math correctly? No! if (0.1 + 0.1 + 0.1 == 0.3) MessageBox::Show("correct"); else MessageBox::Show("not correct");
Corel Paradox:
=, <>
Common comparison operators:
=
equal
<>
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
Syntax Example: 'Does ObjectPAL evaluate the math correctly? No! If .1 + .1 + .1 = .3 Then msgInfo("", "correct") Else msgInfo("", "not correct") endIf
Delphi:
=, <>
Common comparison operators:
=
equal
<>
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
Syntax Example: //Does Delphi evaluate the math correctly? Yes! //Refer to math.pas MaxSingle for more info. if (0.1 + 0.1 + 0.1 = 0.3) then ShowMessage('correct') else ShowMessage('not correct')
Delphi Prism:
=, <>
Same as Delphi. Common comparison operators:
=
equal
<>
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
Syntax Example:
//Does Prism evaluate the math correctly? No! //This is different than later versions of //Delphi that muse MaxSingle in math.pas. If .1 + .1 + .1 = .3 Then MessageBox.Show("correct") Else MessageBox.Show("not correct");
Java:
==, !=
The Java comparison operators are:
==
equal
!=
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
More Info / Comment
JavaScript:
==, !=
Common comparison operators:
==
equal
!=
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
Syntax Example:
//Does JavaScript evaluate the math correctly? No! if (.1 + .1 + .1 == .3) { document.write("correct"); } else { document.write("not correct"); }
Perl:
==, !=
Common comparison operators:
==
equal
!=
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
Perl also offers additional string comparison operators:
eq
string equals
ne
string not equal
lt
string less than
gt
string greater than
le
string less than or equal
ge
string greater than or equal
Syntax Example:
#Does Perl evaluate the math correctly? No! if ((.1 + .1 + .1) == .3) { print("Correct<br>"); } else { print("Not correct<br>"); }
PHP:
==, != or <>
Common comparison operators:
==
equal
!= or <>
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
PHP 4 and above also offers === for indentical (equal plus same type) and !== for not identical (not equal or not same type).
Syntax Example:
//Does PHP evaluate the math correctly? No! if (.1 + .1 + .1 == .3) { echo "correct"; } else { echo "not correct"; }
VB.Net:
=, <>
Save as VB Classic. Common comparison operators:
=
equal
<>
not equal
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
Syntax Example:
//Does VB.Net evaluate the math correctly? No! If 0.1 + 0.1 + 0.1 = 0.3 Then MessageBox.Show("correct") Else MessageBox.Show("not correct") End If