-3

I'm attempting to make a game in which I need to store a large number. I am currently using a int but the number keeps turning negative. Is there a reason this would be happening?

Zoe stands with Ukraine
  • 25,310
  • 18
  • 114
  • 149
Mike
  • 1
  • With some code sample you'll get an answer. – ranieribt Mar 22 '19 at 18:28
  • 1
    Its likely that you may be encountering an integer overflow, but theres no way to figure that out unless you show us the code. – Mercury Platinum Mar 22 '19 at 18:30
  • 2
    Possible duplicate of [How does Java handle integer underflows and overflows and how would you check for it?](https://stackoverflow.com/questions/3001836/how-does-java-handle-integer-underflows-and-overflows-and-how-would-you-check-fo) – Zoe stands with Ukraine Mar 22 '19 at 18:55

1 Answers1

1

This could be because your value is exceeding the range that a int can store. Try using the long variable rather then int

asr9
  • 2,064
  • 1
  • 17
  • 31