Instantly share code, notes, and snippets.

Embed
What would you like to do?

Falsehoods programmers believe about prices

  1. You can store a price in a floating point variable.
  2. All currencies are subdivided in 1/100th units (like US dollar/cents, euro/eurocents etc.).
  3. All currencies are subdivided in decimal units (like dinar/fils)
  4. All currencies currently in circulation are subdivided in decimal units. (to exclude shillings, pennies) (counter-example: MGA)
  5. All currencies are subdivided. (counter-examples: KRW, COP, JPY... Or subdivisions can be deprecated.)
  6. Prices can't have more precision than the smaller sub-unit of the currency. (e.g. gas prices)
  7. For any currency you can have a price of 1. (ZWL)
  8. Every country has its own currency. (EUR is the best example, but also Franc CFA, etc.)
  9. No country uses another's country official currency as its official currency. (many countries use USD: Ecuador, Micronesia...)
  10. Countries have only one currency.
  11. Countries have only one currency currently in circulation. (Panama officially uses both PAB and USD)
  12. I'll only deal with currencies currently in circulation anyway.
  13. All currencies have an ISO 4217 3-letter code. (The Transnistrian ruble has none, for example)
  14. All currencies have a different name. (French franc, "nouveau franc")
  15. You always put the currency symbol after the price.
  16. You always put the currency symbol before the price.
  17. You always put the currency symbol either after, or before the price, never in the middle.
  18. There's only one currency symbol for any currency. (元, 角, 分 are increasing units of the Chinese renminbi.)
  19. For a given currency, you always, but always, put the symbol in the same place.
  20. OK. But if you only use the ISO 4217 currency codes, you always put it before the price. (Hint: it depends on the language.)
  21. Before the price means on the left. (ILS)
  22. You can always use a dot (or a comma, etc.) as a decimal separator.
  23. You can always use a space (or a dot, or a comma, etc.) as a thousands separator.
  24. You separate big prices by grouping numbers in triplets (thousands). (One writes ¥1 0000)
  25. Prices at a single company will never range from five digits before the decimal to five digits after.
  26. Prices contains only digits and punctuation. (Germans can write 12,- €)
  27. A price can be at most 10^N for some value of N.
  28. Given two currencies, there is only one exchange rate between them at any given point in time.
  29. Given two currencies, there is at least one exchange rate between them at any given point in time. (restriction on export of MAD, ARS, CNY, for example)
  30. And the final one: a standalone $ character is always pronounced dollar. (It's also the peso sign.)
@ashb

This comment has been minimized.

ashb commented Sep 10, 2013

It would be useful if you could provide counter examples to say why these are incorrect assumptions.

@garu

This comment has been minimized.

garu commented Sep 10, 2013

Nice compilation! "$" was also the escudo sign before the Euro, and in portuguese we call it "cifrão" when it is standalone.

@MarcelGruenauer

This comment has been minimized.

MarcelGruenauer commented Sep 10, 2013

ashb: Yes, that'd be good. E.g., #17: "the Cape Verdean escudo, like the former Portuguese escudo and French franc, placed its sign in the decimal position (i.e., 20$00)" from http://en.wikipedia.org/wiki/Currency_symbol

@jleader

This comment has been minimized.

jleader commented Sep 10, 2013

Wikipedia claims your list of Chinese currency symbols in #18 is in decreasing order.

Also, if you want to follow the style of the names and times falsehood lists, you could split #18:

  1. There's only one currency symbol for any currency. ($ and ¢ for dollars and cents.)
  2. OK, then, there are at most two currency symbols for any currency. (元, 角, 分 are decreasing units of the Chinese renminbi.)

Also, maybe before #18:

X. A currency symbol (as distinct from a 3-letter currency code) is always a single character. (Rp for Indonesian rupiah.)

@rgs

This comment has been minimized.

Owner

rgs commented Sep 10, 2013

@jleader: good points. I note that the IDR isn't strong enough to buy a Unicode codepoint, like most other currencies...:)
Same remark to @garu, the cifrão is originally written with 2 bars (while the dollar has only one), but it has no separate Unicode codepoint. It is, however, much older than the US dollar, and it's its origin.

@waprile

This comment has been minimized.

waprile commented Feb 28, 2014

number 31: All countries use their own currency. (Zimbabwe)

On Transnistria, it is a bit tricky. The country is officially recognized by very few other countries. http://en.wikipedia.org/wiki/International_recognition_of_Transnistria

@MartinThoma

This comment has been minimized.

MartinThoma commented Aug 28, 2018

Could somebody explain 3 and give a counter example?

@newtrat

This comment has been minimized.

newtrat commented Sep 11, 2018

@MartinThoma The example used in #4 also works for #3, since #4 is a more specific version of #3. The Wikipedia page for MGA lists denominations like 1/5 and 2/5, so presumably you'd talk about 1 1/5 ariary rather than 1.2 ariary. But the website of Madagascar's central bank does list these coins in a decimal format, as ARIARY 0,4 and ARIARY 0,2, so maybe Madagascar has switched to a decimal format since this Gist was written? I don't know how the currency is actually used in practice.

@jrbasso

This comment has been minimized.

jrbasso commented Sep 27, 2018

You can add another entry saying the symbol is not always one character like USD ($)/EUR(). Some currencies use multiple like R$ and others that are even longer.

@calvinmetcalf

This comment has been minimized.

calvinmetcalf commented Nov 6, 2018

Prices can't have more precision than the smaller sub-unit of the currency. (e.g. gas prices)

strictly speaking gas prices are not an example of this since the dollar is not only divided into cents but also divided into dimes (1/10 of a dollar) and mils (1/1000 of a dollar) so gas prices are just denominated in mils, their smaller sub unit.

This is also why the dime just says 'one dime' instead of 'ten cents'.

@calvinmetcalf

This comment has been minimized.

calvinmetcalf commented Nov 6, 2018

@MartinThoma that one is explicitly about pre-decimal British pounds where were divided into 20 shillings each of which was divided into 12 pennies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment