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

-Collapse +Expand ASP Classic Store

Prestwood eMagazine

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

   ► KBWebsite Scri...ASP ClassicTool Basics   Print This    All Groups  
  From the February 2014 Issue of Prestwood eMag
ASP Classic Tool Basics:
ASP Classic Comparison Operators (=, <>)
Posted 14 years ago on 11/10/2008 and updated 10/15/2009
ASP Classic Code Snippet:
 A flashcard from our ASP Classic Flashcards Library
 A code snippet from our ASP Classic 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.

ASP Classic Comparison Operators

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"
Response.Write "not correct"
End If

The Fix

There are several techniques for handling computer rounding errors. For ASP Classic, consider using the Round function. For example:

If Round(.1+.1+.1, 4) = .3 Then
  Response.Write "yes" & "<br>" 'Yes is displayed!
  Response.Write "no" & "<br>"
End If

Reserve Floating Point Values

Because computers have trouble representing floating point values, you may want to reserve the use of floating point literals for imprecise measurements such length, height, weight, etc. The very nature of measurements is imprecise.

More Info

Tip:  Round Floating Point Numbers


Share a thought or comment...
Comment 1 of 2

thank you, you saved my day !

Posted 7 years ago

Comment 2 of 2

I have been looking for information on this subject. I found your post well-written and informative. Thank you!

usa map

Posted 18 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 = P1295A1
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 #101585 Counter
Since 11/10/2008
Sales Website: Or visit our legacy sales site:

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