Copy link to clipboard
Copied
Hi, one of my expressions got disabled due to an "invalid numeric result (divide by 0?)" , but as far as i can see, i am not dividing by 0.
my code:
var f=timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false);
var c= thisComp.height;
var h=(c-1)/2;
var a= f-z*c;
var z=(f/c)-(1/10000000);
var s=4/(c-1);
var x=(-(h+1)+a)*s;
var y=(h-z)*s;
[x,y]
The super weird thing is, that when i change the "z" in var a to "3", the expression works, but when i replace the whole value of var z to "3", i get the same error. Shouldn't the two give the exact same result??
Thanks and kind regards,
i am not dividing by 0.
Sure you are:
var f=timeToFrames()
The result of time conversions like this can be zero and then you are also calculating the millionth fraction of something in var z. For all intents and purposes, there could be quantization and internal rounding errors. Your code seems awfully convoluted, anyway. Why not concatenate and consolidate the functions into a single formula? Even declaring the variables with var= is redundant in JavaScript and does nothing for you.
Mylenium
Copy link to clipboard
Copied
i am not dividing by 0.
Sure you are:
var f=timeToFrames()
The result of time conversions like this can be zero and then you are also calculating the millionth fraction of something in var z. For all intents and purposes, there could be quantization and internal rounding errors. Your code seems awfully convoluted, anyway. Why not concatenate and consolidate the functions into a single formula? Even declaring the variables with var= is redundant in JavaScript and does nothing for you.
Mylenium
Copy link to clipboard
Copied
It's probably because you use the z variable before assigning it a value.
var a= f-z*c;
var z=(f/c)-(1/10000000);
Xavier
Copy link to clipboard
Copied
Hey, thank you guys, both your suggestions work fine, i am tagging Myleniums Answer as the correct one because he was first, but Thanks alot to you too, UQg!! I am really new to AE expressions and coding in general, but i am really interested and learning every day, also thanks to community members like you...:)
I already ran into the next problem in my project, i opened a new discussion and would very much appreciate you giving it a look, if you have time...thanks