In a simple business simulation game (built in Java + Slick2D), which is more suitable to store theshould a player's current amount of money: be stored as a floatfloat
or an intint
, or something else? Some information:
- Most of the transactions will use cents ($0.50, $1.20 and so on)
- There will be interest rate calculations at some point. Simple ones though.
In my use-case, most transactions will use cents ($0.50, $1.20, etc.), and simple interest rate calculations will be involved.
I've seen people saying you should never use floatfloat
for currency, as well as people saying you should never use intint
for currency. I feel like I should use intint
and round any necessary percentage calculations. What's the best solution in this caseWhat should I use?