top | item 44060297

(no title)

koblas | 9 months ago

Some countries don't have cents, some countries have 3 digits of cents. So, yes you can but you also then get thinking you can express everything as ints. But, the moment you need to convert from KWD to VND (84000.00:1) you could be at the edge of the size of a 64 bit int. Note: VND is pretty stable, when currencies start deflating the numbers can get crazy.

discuss

order

eru|9 months ago

Well, obviously you put the smallest unit in your integers.

Cents was just an example. Old British currency used to be even crazier than your example of a unit divided into 1,000.

> But, the moment you need to convert from KWD to VND (84000.00:1) you could be at the edge of the size of a 64 bit int.

So? You should use arbitrary length integers for that. Many languages have good support for them. Eg in Python they are the default integer you get.