During development work on a project, we encountered some strange behavior. We implemented a REST route using the NodeJs framework in version 14. The route accepts a query parameter. When passing the value "9995151671798245" as a string and then parsing it as an integer, we noticed that the result is the integer value 9995151671798244. So the string got subtracted by a value of one.
I was able to reproduce this issue with the following console output:
// Wrong ?
console.log(["9995151671798245", parseInt("9995151671798245", 10), Number("9995151671798245"), Math.ceil("9995151671798245"), parseFloat("9995151671798245")])
// Correct!
console.log(["9995151671798244", parseInt("9995151671798244", 10), Number("9995151671798244"), Math.ceil("9995151671798244"), parseFloat("9995151671798244")])
// Correct!
console.log(["9995151671798246", parseInt("9995151671798246", 10), Number("9995151671798246"), Math.ceil("9995151671798246"), parseFloat("9995151671798246")])
The surrounding numbers are also working as expected. How can it be that the value is subtracted by one during parsing?