I am working with some rather large integers, and need to add some decimals to the number.
I am using the Intl.NumberFormat('en-US')
to place the decimals in the needed place.
That part is working, but after formatting the number, Javascript no longer recognizes it as a valid number.
let numbform = new Intl.NumberFormat('en-US');
console.log("value: ", value); // -765776.6480749019
let test = numbform.format(Number(parseFloat(Number(value).toFixed(Number(arg)))))
console.log("numberform: ", test); // -765,776.648
console.log("typeof: ", typeof test); // string
console.log("Number(test): ", Number(test)); // NaN
i am guessing it has to do with the extra decimals, but i have honestly no idea how to keep the precision, and 'reverse', the NumberFormat
functionality.