Open Gieff opened 3 years ago
A very specific case, especially whit kilos insted of lbs. If the item have a very small weight, the number has a round error https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
I resolved with a function that return better looking numbers (from line:459)
let reduce = (number, precision) => { let factor = Math.pow(10, precision); let n = precision < 0 ? number : 0.01 / factor + number; return Math.round( n * factor) / factor; } return reduce(weight,3);
or in alternative the same solution used for the coins weight can be applied: return Number(weight).toFixed(2);
return Number(weight).toFixed(2);
or using Math.js (but must be an active dependecy): return Math.format(weight,{format:14})
return Math.format(weight,{format:14})
A very specific case, especially whit kilos insted of lbs. If the item have a very small weight, the number has a round error https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
I resolved with a function that return better looking numbers (from line:459)
or in alternative the same solution used for the coins weight can be applied:
return Number(weight).toFixed(2);
or using Math.js (but must be an active dependecy):
return Math.format(weight,{format:14})