3 ms·
Money is an interesting case. The basic units are clear, with most modern currencies having a 3-letter code, and a decimal subdivision of the main unit into 100
by mikhailfranco 3y ago
Money is an interesting case. The basic units are clear, with most modern currencies having a 3-letter code, and a decimal subdivision of the main unit into 100 or 1,000 subunits (or 10^8 satoshis :) Calculations should usually use integer arithmetic in the subunit, with Bankers Rounding.
Historically, there were non-decimal currencies, like British pounds-shilling-pence, with 1:20:12 ratio.
However, each value also needs a timestamp to enable conversions between currencies, or comparisons for the same currency at different times (inflation).
- baq 3y agoA timestamp is not enough. You need the exact market from which you get the price, too.
- eternauta3k 3y agoWhat if there are multiple exchange rates with every person having different access to them?
- NavinF 3y agoThen there are 2 currencies with an exchange rate and transaction fees to convert between them. The black market currency represents the true value whereas the local currency is based on price controls. Eg https://en.wikipedia.org/wiki/Venezuelan_bol%C3%ADvar#Currency_black_market https://en.wikipedia.org/wiki/Venezuelan_bol%C3%ADvar#Curren...
- tgv 3y ago> Calculations should usually use integer arithmetic in the subunit On a computer, for specific purposes. It's a reasonable way to implement certain computations correctly, but has little to do with the topic.
- karatinversion 3y agoOn the contrary, because every currency amount can be expressed as an integer multiple of the lowest denomination, the currency has an intrinsic integer structure
- tgv 3y agoNot in the case of interest. Banks store fractional amounts that only gets rounded when paying or invoicing it.
- naasking 3y agoMoney is not like a unit in a system of units that has fixed relationships. It's not only time-varying but also contextual in other ways, eg. by locale, by financial status or any number of other factors. This is a good analysis of how to represent money so that you can perform arithmetic and check for equality while accounting for contextual conversions: https://deque.blog/2017/08/17/a-study-of-4-money-class-designs-featuring-martin-fowler-kent-beck-and-ward-cunningham-implementations/ https://deque.blog/2017/08/17/a-study-of-4-money-class-desig...