tweenjs / es6-tween

ES6 version of tween.js
MIT License
186 stars 34 forks source link

Fix Big Number #56

Closed moroine closed 6 years ago

moroine commented 6 years ago

Fixes #55

The issue is that numbers are truncate with maximum 4 decimals using

const DECIMAL = Math.pow(10, 4)
result = ( ( value * DECIMAL ) | 0 ) / DECIMAL

The idea here (from what I understood) is that using | 0 will cast the number to an integer.

But the issue is that bitwise cast to a 32 bits integer and Numbers are managed in a 64bits.

( ( Math.pow( 2, 31 ) - 1 ) | 0 ) === Math.pow( 2, 31 ) - 1 // true
( Math.pow( 2, 31 ) | 0 ) === Math.pow( 2, 31 ) // false

So considering the multiplication by DECIMAL we were limited to number bellow 214749...

In my opinion, there is no need for such conversion, I left this behavior in the recompose method as the result is a string and I don't really know how it's working.

dalisoft commented 6 years ago

@moroine Big thanks to you, it's amazing work. Please publish to NPM, i don't have time

dalisoft commented 6 years ago

@sole Please make give access to @moroine

dalisoft commented 6 years ago

@moroine I did limit of decimals to improve performance, but i seem there bug, now you fixed it. Please change this on everywhere possible and i will merge PR