Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NaN when incrementing 1

Status
Not open for further replies.

skrause

Programmer
Feb 10, 2001
18
US
Folks:

ASP issue using Jscript - I am trying to calculate a sum within a for loop (y) using the equation:

c += a[z] * b[y+1];

where a is an array, as is b. c has been declared as a variable.

The result returns as NaN. I've tried parsing (parseInt) both a and b prior to multiplying. Funny thing is, when I remove the + so the eqn reads c = a[z] + b[y+1]; I get the answer I would expect.

Anybody have any suggestions, or am I missing something that is blatantly obvious.

Thanks,
Steve
 
What is the value of C prior to performing your calculation. += says to add the result to the previous value of C, so if the old value of C is not a number, then it'll fale. Just plain = overwrites the old value, so it's not a concern. Also be sure that C is numeric before hand too. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Harold:

That was the problem - and it was pretty blatant after you mentioned it.

Thanks for the help.
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top