I.T. Discussion Community!
 Message Board
 Members Only

#### Prestwood eMagazine

August Edition
Subscribe now! It's Free!

 ► KB ► Desktop Data... ► Paradox & Ob... ► ObjectPAL Co... ► OPAL: Langua...
 Next Random Article Next Random Tidbit || Change Topic Random From All
From the May 2015 Issue of Prestwood eMag
 Paradox OPAL: Language Basics:ObjectPAL Comparison Operators (=, <>)
Posted 11 years ago on 2/11/2009
 To/From Code Guide: ObjectPAL Comparison... vs. Other Languages  A flashcard from our Paradox Flashcards Library  A code snippet from our Paradox Code Snippets Page

### 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: Comparison Operators

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.

### ObjectPAL Comparison Operators

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`

### Overcoming Floating Point Errors

Because computers have trouble with certain floating point values (such as .1), you need to decide what level of accuracy is "good enough" for your application. Perhaps establish a standard for each application. For example, you could establish 6 decimal points as a standard and require all developers to use ObjectPAL's round() method when comparing floating point number. For example, you could rewrite the above routine as follows and get the result you expect.

`If round(.1 + .1 + .1, 6) = round(.3, 6) Then  msgInfo("", "correct")Else  msgInfo("", "not correct")EndIf`

 Tip: Round Floating Point Numbers

Share a thought or comment...
 PS_2916 Comment 1 of 1 Object PAL comparison operators are discussed on this blog page. Things are elaborated and discussed in a very detailed manner on this blog page. And also I found resumespice.com review service on this page which is incredible. Keep sharing more pages like that with us in the best regards of technology and the modern world. Posted 18 days ago