Hacker News new | ask | show | jobs
by sirk390 1674 days ago
But decimal are way more useful as they can represent currency amounts. It would be strange to show a currency amount like "3/4" or "11/12". Personally, the two datatypes I have always been adding manually to json are datetimes and decimals (from python)
1 comments

A currency amount is just a rational number with "1000000" as a denominator.

This is the correct representation, and how Google or the blockchain do it.

I don't thing there is a more "correct" representation. Representing it as a string is equaly correct. Blockchain or banking often represents money as an integer with the smallest divisible unit (cent, or satoshi), but it is not applicable here because there is no smallest divisible unit.