Integer overflow?

Subscribe to Integer overflow? 8 posts

avatar for Mizuchiro Mizuchiro 1 post
Flag Post

I noticed that i had thousands and thousands of trash, literal trash; Rusty screws, squeaky springs, small nuts, etc, and I was wondering if sometime in the future they may cause integer overflow and crash my game. I think flash can support tens of thousands; if not hundreds or thousands of thousands; of integers, but will it someday, eventually, overflow?

 
avatar for mosemizrahi mosemizrahi 421 posts
Flag Post

I don’t think so, wait until one reaches 10000, then you’ll see. You will never reach 100000 anyway.

 
avatar for RedeemedWahrior RedeemedWahrior 213 posts
Flag Post

i’m at 33k screws.

but seeing as you can have 484k wood, we’re probably nowhere near the integer limit yet..

 
avatar for donder donder 10 posts
Flag Post

you will hit an overflow when you reach 2,147,483,648 of something.

 
avatar for mosemizrahi mosemizrahi 421 posts
Flag Post

Wow. How do you know? (Really I wonder)

 
avatar for PauCano PauCano 3 posts
Flag Post

In fact, it would be 4.294.967.296 , because large integers only count up to 32 bits, not 31, as donder posted, The way of calculating it is easy, 2 to the power of the maximum bits, 32

 
avatar for donder donder 10 posts
Flag Post

That’s true if they only use positive numbers. Even in flash, usually, the last bit is for sign so you only get 31 to use for the number itself. Eitherway, you will never be able to do something that will cause an overflow :D

 
avatar for PauCano PauCano 3 posts
Flag Post

Yep, most probably