I wanted to convert the string '9333852702227987'
into a number with the help of the Number()
function when I realized that the output was plus one.
I tried using other methods
to convert the string value
that contains the mentioned number into a number value
, but I still faced the same problem.
let convertToString = function (num1) {
console.log(Number(num1))
console.log(parseInt(num1))
console.log(num1 * 1)
console.log(Math.round(num1))
console.log(Math.floor(num1))
console.log(Math.ceil(num1))
console.log('All results of the ways to convert a string into a number are wrong!!!')
};
convertToString('9333852702227987')
// The result of all of them is: 9333852702227988
Do you know the reason for this?