saferound
is a simplified typescript adaption of the python library Iteround, a sum-safe rounding library.
The library solves the problem of rounding a list of numbers whilst preserving the sum.
import saferound from 'saferound';
const result = safeRound([4.0001, 3.2345, 3.2321, 6.4523, 5.3453, 7.3422], 0); // sum = 30
expect(result).toEqual([5, 3, 4, 6, 5, 7]); // sum = 30
Distributed under the MIT License. See LICENSE
for more information.