How do I convert an integer to a float in JavaScript?
What you have is already a floating point number, they’re all 64-bit floating point numbers in JavaScript. To get decimal places when rendering it (as a string, for output), use .toFixed(), like this: function intToFloat(num, decPlaces) { return num.toFixed(decPlaces); } You can test it out here (though I’d rename the function, given it’s not an … Read more