Ninjastic
Home
Search
Users
Boards
Addresses
Ctrl + K
Toggle theme
Open menu
Post
Edited versions
Quotes to this post
Post
10239868
Topic
814863
Board
Development & Technical Discussion
Re: how to handle btc in javascript
by
jxm262
on
23/01/2015, 19:47:06 UTC
I know this is kind of something you can google yourself (or probably have), but here's a couple SO links with some more info.
http://stackoverflow.com/questions/1458633/elegant-workaround-for-javascript-floating-point-number-problem
http://stackoverflow.com/questions/2876536/precise-financial-calculation-in-javascript-what-are-the-gotchas
http://floating-point-gui.de/languages/javascript/
FWIW, I typically use parseFloat, then toFixed(2) when trying to convert to currency format. Of course this depends on the precision required though.
Example: parseFloat("23432.234324").toFixed(2); //"23432.23"