Closed
Description
little known fact: javascript's Math.round(n)
is asymmetric; it will round negative numbers towards +∞:
console.log(Math.round(1.5)) // 2 probably we expected this
console.log(Math.round(-1.5)) // -1 what the fack?
because all of our vector modules rely on the built-in Math.round
we get this probably unexpected behavior:
const out = vec2.create()
console.log(vec2.round(out, [-1.5, -1.5 ])) // out === [ -1, -1 ]
This is probably not what most people are expecting. In my own games/simulations I use this module https://www.npmjs.com/package/round-half-up-symmetric to fix this behavior.
Would you be open to a PR that leverages this module wherever we use Math.round(n)
?
Metadata
Metadata
Assignees
Labels
No labels