QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Prithak on August 21, 2018, 03:24:09 am

Title: Overflow
Post by: Prithak on August 21, 2018, 03:24:09 am
I've been working on two-dimensional arrays recently because my school is teaching it right now and I was making a very simple game about fighting or somethin' then I got this error.

"OVERFLOW"

What does it mean and can it be fixed? If you need the program then ask me. I won't post it in this box because it is a hassle to set up the whole thing! So. Yeah!

Can i fix this?
Title: Re: Overflow
Post by: Petr on August 21, 2018, 10:36:07 am
'overflow: Let say, you use _UNSIGNED _BYTE type variable. This type maximum value is 255. What, if this value is bigger?

DIM a AS _UNSIGNED _BYTE
a = 255
PRINT a
a = 256
PRINT a

'as you see, second value is not 255, but 0. Its, because QB64 test it and return this  value after overflow back to begin.

a = 255 * 2 'return 254 - because 255 * 2 = 510 = 510 - 256 = 254. Zero is as 1.
PRINT a

'so for testing it, you muss know variable type and maximum value, which can be used for this variable type.