ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Floating point trouble

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Terje Lundgren
Floating point trouble
on Oct 9, 2017 at 9:53:32 am

I have a variable called "workDur", which is assigned the result of calculating floating point values (from different layer.inPoints/outPoints & prop.keyTime().

The workDur value is then assign to activeComp.workAreaDuration. But it ends up being a slightly higher number.

Any thoughts on why and how to solve?



// ..
alert(workDur); // Result: 1.2
activeComp.workAreaDuration = workDur;
alert(activeComp.workAreaDuration); // Result: 1.20000004768372




/Terje


Return to posts index

Andrei Popa
Re: Floating point trouble
on Oct 9, 2017 at 11:04:14 am

I'm not sure why the comp has this slightly longer duration. Maybe due to framerate or something, they can not exactly divide it. But i don't know why this 40 nanoseconds trouble you :D

Andrei


Return to posts index

Terje Lundgren
Re: Floating point trouble
on Oct 9, 2017 at 11:41:15 am



It renders an extra frame. Quite annoying when the purpose is to create seamless loops.

/Terje


Return to posts index


Andrei Popa
Re: Floating point trouble
on Oct 9, 2017 at 2:52:17 pm

Maybe you should differently declare the workDur. figure out the number of frames you wish to have(i named it framesNumber) and try something like
workDur = framesNumber*app.project.activeItem.frameDuration

Andrei


Return to posts index

Terje Lundgren
Re: Floating point trouble
on Oct 10, 2017 at 12:08:47 pm

Assuming a 25 fps comp (CC2014), even hard-coding 122 frames (122*myComp.frameDuration = 4.88 seconds) gives an unexpected result:
app.project.item(1).workAreaStart = 4.88;
alert(app.project.item(1).workAreaStart);
// Result: 4.88000011444092
Manually typing "B" to set the workArea start in AE, brings it back to 4.88 seconds (when checking app.project.item(1).time).


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]