[Gambas-user] Variable overflow questions

user demosthenesk at ...626...
Wed Nov 3 09:47:20 CET 2010


Hi i check the overflow of variables and there is something i dont
understand.

My system is 

user at ...2493...:~$ cat /etc/*release*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.1 LTS"

Linux ubuntu-desktop 2.6.32-25-generic #45-Ubuntu SMP Sat Oct 16
19:52:42 UTC 2010 x86_64 GNU/Linux



I have this small code
-----------------------------------
' Gambas class file
PUBLIC SUB Form_Open()

DIM bVar AS Boolean = TRUE
DIM iNum AS Byte = 255
DIM iA AS Short = 32767
DIM iRoads AS Integer = 2147483647
DIM iBig AS Long = 9223372036854775807
DIM iArea AS Single = 1.7014118E+38 
DIM fPi AS Float = 8.98846567431105E+307 

bVar += 1
iNum += 1
iA += 1
iRoads += 1
iBig += 1
iArea += 1
fPi += 1

PRINT bVar
PRINT iNum
PRINT iA
PRINT iRoads
PRINT iBig
PRINT iArea
PRINT fPi

END
-----------------------------------

And i get the following result

False
0
-32768
-2147483648
-9223372036854775808
1.701411834605E+38
8.988465674311E+307


My question is why the Single and Float do not overflow?

I got this values from the Gambas help and i think these are the upper
values of variables.

i expected the Single to be -1,7014118+38 according to help (did you
mean -1,7014118 (E) +38?)

And for Float to overflow to -8.98846567431105E+307







More information about the User mailing list