YVND
YVND

Reputation: 379

Should i convert all my vars to BigInteger for easier operations

I'm making a game. In this game there is no limit (except technical limits) to money value. I'm currently using a long to store the money value, but the max value is quickly reached.

I found a Java class BigInteger but i don't know if it's the best solution because the money value make operations with long and int values.

Should i convert everything to BigInteger to make "easier" operations or is there a better solution?

Upvotes: 0

Views: 62

Answers (1)

goedi
goedi

Reputation: 2113

If money values are bigger than the long maximum value and do not have a decimal part then use BigInteger, otherwise use BigDecimal.

Upvotes: 1

Related Questions