Hello,
I have heard that one should avoid using float and double in monetary
calculation because of the lack of preciseness.
This is certainly a viewpoint. For what its worth, I work in
investment banking, and we find doubles quite adequate even for large
scale financial transactions. In over a decade in the buisness I have
come across only a couple of instances where it actually mattered.
What is a good alternative?
If you want perfect precision, use integer types, and a scaling factor
to turn back into pennies. Note that this can limit your range unless
you use special big number handling routines. The assets of many a
company, converted into say Turkish Lira, would overflow most builtin
types. It may also be slower, esp if you have to use a special
library.