TinyColor
TinyColor copied to clipboard
The problem with float-point-numbers in the "mix" test
It is the problem of storing floating point numbers in javascript
look at this line
https://github.com/bgrins/TinyColor/blob/master/test/test.js#L724
here (1 - (i / 100))
in this example if we assign "i" as 8, we get this result:
i = 8;
(1 - (i / 100)); // => 0.9299999999999999
but in real life 1 - 8/100 = 1 - 0.08 = 0.92
Tests are passed well, though contain this error.
Probably the same problem is present in the implementation of the mix method.
i fixed this problem in the following way: before:
i = 8;
(1 - (i / 100)); // => 0.9299999999999999
after:
i = 8;
(100 - i) / 100; // => 0.92
also i fixed implementation of method "mix"
now is looks very simple
bump
Please see the comment at #124
OK thanks. I am currently a little busy. within a week I will add checks in tests
bump