I am on ubuntu 9.04, x86, 32bit, gambas 2.12. I have some confusion regarding the following:
---------------------------- PUBLIC SUB Main() DIM myBoolean AS Boolean DIM myByte AS Byte DIM myShort AS Short DIM N, myInteger AS Integer DIM myLong AS Long DIM mySingle AS Single DIM myFloat AS Float PRINT "RANGES" myByte = 255 PRINT "Max value in Byte " & myByte myByte += 1 ' Wraps OK; No BUG PRINT "Min value in Byte " & myByte ' Short (2-Bytes) is 16 bit; 2^16=65536; half is 32768; ie -32768 to 32767 myShort = 32767 PRINT "Max value in Short " & myShort myShort += 1 ' Wraps OK; No BUG PRINT "Min value in Short " & myShort ' Integer (4-Bytes) 2^bits = 2^32 = 4294967296; (4294967296/2=2147483648); -2147483648 to 2147483647 myInteger = 2147483647 PRINT "Max value in Integer " & myInteger myInteger += 1 ' Wraps OK; No BUG PRINT "Min value in Integer " & myInteger ' Long (8-Bytes) 2^bits = 2^64; -9223372036854775808 to 9223372036854775807 myLong = 9223372036854775807 PRINT "Max value in Long " & myLong myLong += 1 ' Wraps OK; No BUG PRINT "Min value in Long " & myLong ' Single (4-Byte C Float) 1.2e-38 to 3.4e38 mySingle = 3.4e+38 PRINT "Max value in Single " & mySingle mySingle += 1 '1e+36 ' Issues PRINT "Min value in Single " & mySingle ' Float (4-Byte C Double) 2.2e-308 to 1.8e308 'myFloat = 1.8e+308 BUG: Cant hold this value myFloat = 1.79e+308 PRINT "Max value in Float " & myFloat myFloat += 1 ' BUG: DoesNOT Wrap PRINT "Min value in Float " & myFloat END ---------------------------- Program Output: ---------------------------- RANGES Max value in Byte 255 Min value in Byte 0 Max value in Short 32767 Min value in Short -32768 Max value in Integer 2147483647 Min value in Integer -2147483648 Max value in Long 9223372036854775807 Min value in Long -9223372036854775808 Max value in Single 3.399999952144E+38 Min value in Single 3.399999952144E+38 Max value in Float 1.79E+308 Min value in Float 1E+2147483647 ---------------------------- I have issue in Single and Float: 1. How to overflow the Single and Float? 2. Why does the Float not accept the highest value? Thanks in advance. :working: -- View this message in context: http://www.nabble.com/Confusion-in-Data-Types-tp23921847p23921847.html Sent from the gambas-user mailing list archive at Nabble.com. ------------------------------------------------------------------------------ OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get _______________________________________________ Gambas-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gambas-user
