Your full service technology partner! 
-Collapse +Expand
Search Paradox Group:

-Collapse +Expand Paradox To/From
-Collapse +Expand Paradox Store

Prestwood eMagazine

October Edition
Subscribe now! It's Free!
Enter your email:

   ► KBDesktop Data...Paradox & Ob...ObjectPAL Co...OPAL: Langua...   Print This     
  From the May 2015 Issue of Prestwood eMag
Paradox OPAL: Language Basics:
ObjectPAL Comparison Operators (=, <>)
Posted 12 years ago on 2/11/2009
Paradox Code Snippet:
 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")
msgInfo("", "not correct")

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")
msgInfo("", "not correct")

More Info

Tip:  Round Floating Point Numbers


Share a thought or comment...
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 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 15 months ago
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1182A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

 KB Article #101875 Counter
Since 2/11/2009
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site:

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