Wrox Programmer Forums negative number returned when subtracting
 | 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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersâ€™ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
November 29th, 2005, 06:04 AM
 Registered User Join Date: Nov 2005 Location: , , . Posts: 7 Thanks: 0 Thanked 0 Times in 0 Posts
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.

November 29th, 2005, 06:16 AM
 Friend of Wrox Join Date: Jul 2003 Location: , , United Kingdom. Posts: 683 Thanks: 0 Thanked 1 Time in 1 Post

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

Chris

November 29th, 2005, 06:34 AM
 Registered User Join Date: Nov 2005 Location: , , . Posts: 7 Thanks: 0 Thanked 0 Times in 0 Posts

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.

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is OffTrackbacks are Off Pingbacks are On Refbacks are Off Forum Rules

 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 03: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 03:36 PM.