3 ms·
The article is right, you should use integers for the number of cents (or whatever the smallest unit of the currency is). That is easy enough as long as you are
by TorKlingberg 7y ago
The article is right, you should use integers for the number of cents (or whatever the smallest unit of the currency is). That is easy enough as long as you are just adding and subtracting, but what do you do about multiplication and division? How do you calculate interest or yearly yields? I think the answer is fixed point, but that is not easy.
- riskneutral 7y agoNo, the answer is floating point.
- viraptor 7y agoWhat problem do you see with multiplication or division? You can still do those with the precision you need, followed by the legally valid rounding for the use case. Unless you don't have a use case where those are defined/relevant, then ¯\_(ツ)_/¯