EndlessVanguard / bitcoin-remunerate-api

A scheme for trustless, decentralized, anonymous, remuneration for content creators.
1 stars 0 forks source link

Invoices in other currencies than satoshis #28

Closed mattgstevens closed 8 years ago

mattgstevens commented 8 years ago

We will want to store and do maths as integers since floating point math is not precise http://stackoverflow.com/questions/588004/is-floating-point-math-broken

When we support other currencies, we can translate from a "natural" currency number (like $5.67 or 5,67€) to our internal representation in pennies 567. Stripe is also storing the amount as an int for similar reasons https://stripe.com/docs/api#charge_object-amount

fromheten commented 8 years ago

How can we archive this?

Let me know what you think @mattgstevens :)

fromheten commented 8 years ago

I implemented this, disregarding floating point rounding errors. It is right to be correct but done is better than perfect and worse is better.

Correct me if I'm wrong, but the rounding errors are on the order of 10^-17 (since 0.2 + 0.1 === 0.30000000000000004). Worth it to ship quick.