p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 29th, 2005, 06:04 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default negative number returned when subtracting

Hello wondering if anyone can help me.

I am performing a calulcation on two numbers (a - b) that are not always the same and i get returned a negative number which is incorrect.

For example if a = 10, and b = 7 then 10 - 7 = 3, but if a = 7, and b = 10 then 7 - 10 = -3.

i am just wondering how in asp code i can fix it so that the result would always be 3 and not -3

Any help would be appreciated

G.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old November 29th, 2005, 06:16 AM
Friend of Wrox
Points: 1,374, Level: 14
Points: 1,374, Level: 14 Points: 1,374, Level: 14 Points: 1,374, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 685
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use Abs() to do this...
Code:
myNum = Abs(a - b)
HTH,

Chris

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old November 29th, 2005, 06:34 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks alot, will try to use abs. Was just starting to write if a > b then make highNumber else make lowNumber etc..

Abs will save me alot of time as have many calculations to perform

G.



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Making a number negative Corey Access 1 February 2nd, 2007 11:48 AM
Subtracting Quantities rsm42 ASP.NET 1.0 and 1.1 Basics 2 January 7th, 2007 10:44 AM
Dynamic number of columns returned from sp dreadjr BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 1 July 5th, 2006 04:42 PM
Subtracting a value from a previous value Wes Access 8 March 29th, 2006 12:17 PM
SUM operator returns a negative number cdias XSLT 7 December 31st, 2004 05:08 PM



All times are GMT -4. The time now is 12:05 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc