Skip to main content
4 of 4
replaced http://gamedev.stackexchange.com/ with https://gamedev.stackexchange.com/

Even if it's "only a game", I would use Money Pattern from Martin Fowler, backed up by a long.

Why?

Localization (L10n): Using that pattern you can easily localize your game currency. Think about the old tycoon games like "Transport Tycoon". They easily allow the player to change in-game currency (i.e From British Pound to US Dollar) to meet real world currency.

And

The long data type is a 64-bit signed two's complement integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive) (Java Tutorials)

That means you can store 9,000 times current M2 US Money Supply (~10,000 Billion Dollars). Giving you enough room to use any other world currency, probably, even those who had/has hyperinflation (If curious, see post-WWI German inflation, where 1 pound of bread was 3,000,000,000 marks)

Long is easy to persist, very fast and should give you enough room to do all interest calculations using only integer arithmetics, eBusiness answer gives an explanation on how to do that.

grprado
  • 695
  • 1
  • 5
  • 9