I.T. Discussion Community!
-Collapse +Expand
ASP Classic
Search ASP Classic Group:

Advanced
-Collapse +Expand ASP Classic Store

Prestwood eMagazine

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

   ► KBWebsite Scri...ASP ClassicTool Basics   Print This     
  From the February 2014 Issue of Prestwood eMag
 
ASP Classic Tool Basics:
ASP Classic Comparison Operators (=, <>)
 
Posted 11 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

KB101585



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"
Else
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!
Else
  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

Comments

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

thank you, you saved my day !

---
mathiew
Posted 39 months ago

Comment 2 of 2

ASP Classic Comparison Operators is the perfect idea of working and people will like this blog. I am sure about the main focus of this blog which is good for assignment writers idea.I just like this idea of blogging so much.

Posted 11 days 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 play-drums.com 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
23882
Since 11/10/2008
-
   Contact Us!
 
PrestwoodBoards.com was developed and is maintainted by me. Do you have a question or suggestion? Do you see a problem? Contact me now. My goal is to build an ad-free and spam-free source of I.T. information with many contributers (ok to promote your website/company in your bio). Yes, my company Prestwood IT Solutions is mentioned in my bio which shows with every post, but you can contribute and promote your pet project too!

2,169 People Online Now!!  
Sign In to see who's online now!  Not a member? Join now. It's free!
Show more stats...


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech