Last 12 weeks · 0 commits
4 of 6 standards met
must be consistent with when dealing with fractional portion being exactly 0.5: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round#description If the fractional portion is exactly 0.5, the argument is rounded to the next integer in the direction of +∞. This differs from many languages' functions, which often round half-increments away from zero, giving a different result in the case of negative numbers with a fractional part of exactly 0.5. I suggest that this should be the behavior a JavaScript developer should expect: Previous discussions: https://github.com/sindresorhus/round-to/issues/6 https://github.com/sindresorhus/round-to/pull/8 https://github.com/sindresorhus/round-to/issues/28 (about NOT returning values rounded to -0) Note also that's how Lodash works: https://github.com/lodash/lodash/issues/4529#issuecomment-547270175 See also https://en.wikipedia.org/wiki/Rounding#Comparison_of_approaches_for_rounding_to_an_integer I think the exact description is "Half Up (toward +∞)". !Screenshot 2023-08-09 at 09 26 18
Repository: sindresorhus/round-to. Description: Round a number to a specific number of decimal places: 1.234 → 1.2 Stars: 159, Forks: 10. Primary language: JavaScript. Languages: JavaScript (97.5%), TypeScript (2.5%). License: MIT. Latest release: v7.0.0 (9mo ago). Open PRs: 0, open issues: 0. Last activity: 9mo ago. Community health: 71%. Top contributors: sindresorhus, Richienb, amrali-eg, BendingBender, ruipneves, SamVerschueren, sebastiansandqvist, yvele.