Coder Social home page Coder Social logo

Comments (5)

bcardarella avatar bcardarella commented on May 30, 2024 2

Yes, it is an incredibly small value and I'm sure an argument could be made about managing floating point precision but considering some of the other functions defer to 0 if x === 0 it stands to reason to have something similar here.

from easings.net.

clickyclick avatar clickyclick commented on May 30, 2024

= 1 + c3 * pow(x - 1, 3) + c1 * pow(x - 1, 2);
= 1 + 2.70158 * pow(0 - 1, 3) + 1.70158 * pow(0 - 1, 2); // x = 0
= 1 + 2.70158 * pow( - 1, 3) + 1.70158 * pow( - 1, 2);
= 1 + 2.70158 * (-1) + 1.70158 * 1; // we know -1^2 is 1 while -1^3 is -1 still
= 1 - 2.70158 + 1.70158 ;
= 0

Here is my work for arriving at 0 as output with a 0 input. Seems correct to me.

from easings.net.

bcardarella avatar bcardarella commented on May 30, 2024

See in JavaScript:
Screen Shot 2022-02-16 at 10 07 21 AM

And in Elixir:
Screen Shot 2022-02-16 at 10 08 16 AM

from easings.net.

clickyclick avatar clickyclick commented on May 30, 2024

Ah I see, format your output to a certain number of decimal places seems like the proper solution.

https://stackoverflow.com/questions/1458633/how-to-deal-with-floating-point-number-precision-in-javascript

from easings.net.

Cleroth avatar Cleroth commented on May 30, 2024

Changing c1 to 1.701575 works. Effect should be very minor.

from easings.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.