I am trying to convert some code from C++ to JavaScript but I am very confused with ints
, doubles
, NaN
and parsing floats. I think!?
Z = T - 14 - (1);
while (Z <= T)
{
var S1 = 0.0;
for (var C = 0; C <= P - 1; C++)
{
if (V[Z + C] !== undefined)
{
skip = 0;
S1 = S1 + (V[Z + C] + V[Z + C]) / 2;
}
else
{
skip = 1;
}
}
console.log('S1: ' + S1);
Z++;
}
S1
is now always NaN
how do I stop this? (something to do with typeof
?)
On a good note: I've got the V=[]
part to work and that uses doubles and am working on the undefined part (messy fix) so that is some good progress.