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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting 'undefined' as an answer...how come? 1

Status
Not open for further replies.

kanin247

Programmer
Apr 23, 2001
113
US
I'm getting the result 'undefined' in my output...is it because the result of the log function is negative? If so, how could I correct this problem?

Thanks for you help. ~kanin

Here's my code:

function GetReactance(numSelection)
{
var KV = 46;
var MILG = .19;
var EQSP = .45;
var XFPRIM = .399;
var XF = ((XFPRIM*100.0)/(KV*KV));
var XDPRIM = ((0.2793881)*((Math.log(EQSP))/(Math.ln10)));
var XS = ((XDPRIM*100.0)/(KV*KV));
var REACT = ((XF+XS)*MILG);
if(REACT < 0)
{
var roundedREACT = parseInt((REACT*1000000)-0.5)/1000000;
}
else if(REACT > 0)
{
var roundedREACT = parseInt((REACT*1000000)+0.5)/1000000;
}
document.forms.frmCoordinates.OutputREACT.value = roundedREACT;

Output: undefined //The answer should be 0.002713
 
Hi Kanin247,

correct this line
var XDPRIM = ((0.2793881)*((Math.log(EQSP))/(Math.ln10)));
to
var XDPRIM = ((0.2793881)*((Math.log(EQSP))/(Math.LN10)));

this should solve your problem.. =)

Chiu Chan
WebMaster & Software Engineer
emagine solutions, inc
cchan@emagine-solutions.com
 
My program FINALLY works correctly...thanks alot!

~kanin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top