Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Floating point trouble

  • Floating point trouble

    Posted by Terje Lundgren on October 9, 2017 at 9:53 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

    Terje Lundgren replied 8 years, 7 months ago 2 Members · 4 Replies
  • 4 Replies
  • Andrei Popa

    October 9, 2017 at 11:04 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 😀

    Andrei

  • Terje Lundgren

    October 9, 2017 at 11:41 am

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

    /Terje

  • Andrei Popa

    October 9, 2017 at 2:52 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

  • Terje Lundgren

    October 10, 2017 at 12:08 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).

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy