I am storing international currency amounts in my database as minor units to avoid floating-point arithmetic.
I am also storing the locale in my database to provide the context in order to display a formatted string representation of the amount.
For example, if I have two rows as follows:
529 US-en
529 ja-JP
I want to display on the front-end
$5.29
¥529
I have found the docs for Intl.NumberFormat()
but it appears that you have to already have your numbers represented as major units only.
Is there a methodology that anyone has implemented for such a use-case WITHOUT knowing the ratio of minor units to major units for EVERY currency you wanted to support?
Basically is there a way I can just leverage the Intl.NumberFormat()
function and have it consider the number I give it to be in minor units and then convert it to major accordingly?