ASP and Using Math

# Thread: ASP and Using Math

1. Member
Join Date
Dec 1969
Posts
34

## ASP and Using Math

Hello All<BR><BR>I am trying to Calculate the difference between two numbers as a percentage<BR><BR>Which is as Follows (From Excel Help)<BR>%Difference =(B2-A2)/ABS(A2)<BR><BR>In Perl I get the correct Answer as Follows<BR><BR>my \$DataforWeekEnding = 10594;<BR>my \$PriorWeekData = 15669;<BR><BR>\$total = (\$DataforWeekEnding - \$PriorWeekData) / abs (\$PriorWeekData) ;<BR><BR>Answer = -0.323887931584658 (Correct)<BR><BR><BR>In ASP the the following DOES NOT give me the correct Answer<BR><BR>DataforWeekEnding = 10594<BR>PriorWeekData = 15669<BR><BR>Percent = (DataforWeekEnding - PriorWeekData ) / ABS(PriorWeekData)<BR><BR>ASP - 0.325179947767374<BR><BR>What am I doing wrong, I converted the Vars to Int and still no luck. <BR><BR>Please and help I spent all night on this easy question. <BR><BR>Best <BR>Stuart<BR><BR><BR><BR><BR><BR><BR><BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
731

## take away

abs function...

3. Senior Member
Join Date
Dec 1969
Posts
170

## RE: ASP and Using Math

Hi Stuart,<BR><BR>I gave it a try and got the right answer.<BR><BR>Exact code used:<BR><BR>&#060;%<BR>&#039;Answer = -0.323887931584658 (Correct) <BR>&#039;In ASP the the following DOES NOT give me the correct Answer <BR><BR>DataforWeekEnding = "10594"<BR>PriorWeekData = "15669" <BR><BR>Percent = (DataforWeekEnding - PriorWeekData) / ABS(PriorWeekData)<BR>&#039;Percent = DataforWeekEnding - PriorWeekData<BR>&#039;Percent = Percent / PriorWeekData<BR>&#039;ASP - 0.325179947767374 <BR>Response.Write Percent<BR>%&#062;

4. Member
Join Date
Dec 1969
Posts
34

## RE: ASP and Using Math

Thanks <BR><BR>I entered a "6" when it should have been a "9" in my data that is why the value was comming out different. <BR><BR>Bitten by a stupid mistake, thanks for proving that my code worked !!!!<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•