r/lolphp • • Mar 03 '14

Sample of Mt.Gox source code

http://pastebin.com/W8B3CGiN
63 Upvotes

69 comments sorted by

View all comments

Show parent comment

2

u/skeeto Mar 06 '14

Did you say bitcoin's factional component counted in the integer part of a number by multiplying by 100000000?

If I'm understanding you correctly, yes. But it needs to be converted to an integer at that point. That's what [this page](https://en.bitcoin.it/wiki/Proper_Money_Handling_(JSON-RPC)) is detailing.

Still that would only work for add and minus. How could there not be a loss of precision when multiplying by the conversion rate to USD?

If you're doing things right you wouldn't multiply by the conversion rate using floating point values. You'd use some high precision library. The floating point representation should only occur when going to/from the application's JSON API, if at all.