Javascript numerical calculation concerns
I am implementing a cu开发者_StackOverflowrrency converter with javascript, e.g., convert USD to SGD. Do you know any article or trick about concerns like precision issue that I need to tackle?
Thanks.
Accuracy seems to be the biggest issue here. There are many good sources to be found around the internet. This short article by William Bontragerone handles the accuracy problem sufficently.
Just retain precision until you have to display the results on the page. And always prepare for the possibility that the user could put anything as input, including telephone numbers.
精彩评论