IT SOLUTIONS
Your full service technology partner!     To/From Code  Languages  Categories  Corel Paradox Guides  Browse Language COREL PARADOXLANGUAGE Corel Paradox ◄╣  Members-Only Sign in to see member-only pages.
 ► KB ► To/From Guides ► Corel Paradox

## Comparison Operators

#### General Info: Round Floating Point Numbers

When comparing floating point numbers, make sure you round to an acceptable level of rounding for the type of application you are using.

#### Languages Focus

A comparison operator compares two values either literals as in "Hello" and 3 or variables as in X and Counter. Most languages use the same operators for comparing both numbers and strings. Perl, for example, uses separate sets of comparison operators for numbers and strings.

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` ObjectPAL Comparison Operators (=, <>)

## Cross Reference Examples:

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` ASP Classic Comparison Operators (=, <>)
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");`
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 Comparison Operators (=, <>)
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

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
");} else { print("Not correct
");}`
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 Classic:   =, <> Common comparison operators:

 = equal <> not equal < less than > greater than <= less than or equal >= greater than or equal
 Syntax Example: `//Does VB evaluate the math correctly? No!``If 0.1 + 0.1 + 0.1 = 0.3 Then MsgBox "correct"Else MsgBox "not correct"End If`
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`

-
 Contact Us! Have a question? Need our services? Contact us now. --Mike Prestwood Call: 916-726-5675 email: info@prestwood.com 8421 Auburn Blvd, STE 256, Citrus Heights, CA 95610
 Go ahead!   Use Us! Call: 916-726-5675

 ©1995-2019 Prestwood IT Solutions.   [Security & Privacy]