Try this in QBasic: A& = &H80 B& = &H8000 C& = &H800000 D& = &H80000000 PRINT A& PRINT B& PRINT C& PRINT D& END The output: 128 -32768 8388608 -2147483648 Makes it pretty tough to use 32-bit quantities...
Posted on 2001-06-12 11:00:00 by Larry Hammick
Yes, they are supposed to be long (32-bit) ints. So why does &H8000 have a sign?
Posted on 2001-06-13 20:52:00 by Larry Hammick
They are 32-bits -- one of which is for the sign. I don't know QBasic, but it appears to not support unsigned 32bit -- at least not with the notation above. :) The integer range is H80000000 to 0 to H7FFFFFFF. So, you do have 32bits to work with, but you'll have to offset all your numbers by H80000000 to use all those bits if you don't have negitive numbers. :)
Posted on 2001-06-13 23:54:00 by bitRAKE
I know how negative numbers are represented: the high bit is set. Therefore &H8000, if it is 32 bits, should be positive.
Posted on 2001-06-14 02:04:00 by Larry Hammick
Solved it, if you can call it a solution. This doesn't work: DIM A AS LONG A& = &H8000 PRINT A& for you just get -32768 as before. However: A& = &H8000& 'Need to include the trailing "&" PRINT A& gives +32767.
Posted on 2001-06-15 01:05:00 by Larry Hammick
Ah, yes, conversion rules. &H8000 is a 16-bit number. When you assign 16-bit to 32-bit, the value gets sign-extended. The problem is that none of MS's Basics support any notion of unsigned-ness.
Posted on 2001-06-19 21:17:00 by tank