?
Solved

How to check if number is positive or negative

Posted on 2006-11-18
6
Medium Priority
?
6,538 Views
Last Modified: 2012-05-05
In classic asp, how do I check if a number is positive or negative.
Say 20 - 10 = -10. How do i check if its - 10?
I'm tryin to do a sales report graph where todays data is compared with yesterdays and the percent of increase or decrese is displayed.
So if its -10 Response.write "Decrease in Sales"
0
Comment
Question by:dpinto04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 25

Expert Comment

by:kevp75
ID: 17973893
you can format a number....

<%=formatnumber(strNumber,2,0,-1)%>

this will put a parentheses around a negative number....so I guess, you could always do a string check against it...

if instr(formatnumber(strNumber,2,0,-1),"(") > 0 then
  response.write("Decrease In Sales"
end if
0
 
LVL 16

Accepted Solution

by:
CWS (haripriya) earned 80 total points
ID: 17977497
Dim numA, numB, numDiff

numDiff = numA - numB

' All negative numbers are less than zero.
if numDiff < 0 then
      Response.write "Decrease in Sales"
end if

0
 
LVL 9

Expert Comment

by:deathtospam
ID: 17979465
The VBScript Sgn function ( http://tinyurl.com/yz9rpo ) sounds like what you need:

====================================
Arguments
The number argument can be any valid numeric expression.

Return Value
The Sgn function has the following return values:

If number is  Sgn returns  
Greater than zero
 1
Equal to zero
 0
Less than zero
 -1
====================================


-= DeathToSpam =-
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question