Quote: "That's a little mixed up.
a BYTE is 8 bits
a WORD is 2 bytes = 16 bits
a DWORD is a double WORD so it's 4 bytes = 32 bits"
Whoops sorry i meant the values. arn't those the max values for the different data types?
Quote: "There's a left shift << and a right shift >> . Think of left shift as multiply think of right shift as divide.
"
Ya i figured that out. lol whoops
Quote: "That's an interesting concept. I only see the data types as how many bytes they take up in a file and the ranges of numbers I can use them with. It would be interesting to be able to store 32 switches in only 4 bytes using BIN$(). I normally use 1 byte per switch when saving data."
Ya i see it as abunch of data you can store. so you can have the let's say BYTES of date that you need then store 2 of those in words then do that again, thats 4 sets of values then put it in a dword. thats 4 sets of data that is compressed into one variable. that's the way i see i could use this.
here's what i've got:
Sync on
Sync rate 0
Randomize Timer()
Dim Byte(4)
for X=1 to 4
Byte(X) = RND(11)
next X
WORD1 = MAKEWORD(BYTE(1), BYTE(2))
WORD2 = MAKEWORD(BYTE(3), BYTE(4))
DWORD = MAKEDWORD(WORD1, WORD2)
LOWORD = LOWORD(DWORD) : HIWORD = HIWORD(DWORD)
PRint "DWORD >> " ; DWORD
Print "LOWORD >> " ; LOWORD
Print "HIWORD >> " ; HIWORD
Print "WORD 1 >> " ; WORD1
Print "WORD 2 >> " ; WORD2
Function MAKEDWORD(W1, W2)
DWORD = (W1 & 65535) | ((W2 & 65535) * (2 ^ 16))
endfunction DWORD
Function MAKEWORD(B1, B2)
WORD = (B1 & 255) | ((B2 & 255) * (2 ^ 8))
endfunction WORD
Function LOWORD(DWORD)
LOWORD = (DWORD & 65535)
endfunction LOWORD
Function HIWORD(DWORD)
HIWORD = (DWORD / (2 ^ 16)) & 65535
endfunction HIWORD
Function LOBYTE(WORD)
LOBYTE = (WORD) & 255
endfunction LOBYTE
Function HIBYTE(WORD)
HIBYTE = (WORD / (2 ^ 8)) & 255
endfunction HIBYTE
Function LOBIT(BYTE)
LOBIT = (BYTE) & 15
endfunction LOBIT
Function HIBIT(BYTE)
HIBIT = (BYTE / (2 ^ 1)) & 15
endfunction HIBIT
OH! i found the highest integer value for dbc lol....
it's:
4294967295
anything over tht registers as 0. i tried to do one step above dword(2 DWORDS) and i did << 32 (2 ^ 32) and it makes this:
4294967296
Which registers as 0 in dbc. lol
EDIT:
Hey Would this make a byte out of bits?
Function MAKEBYTE(B1, B2, B3, B4, B5, B6, B7, B8)
BYTE = (B1 & 15) | ((B2 & 15) * 2) | ((B3 & 15) * 4) | ((B4 & 15) * 6) | ((B5 & 15) * 8) | ((B6 & 15) * 10) | ((B7 & 15) * 12) | ((B8 & 15) * 14)
endfunction BYTE
Because each one offsets by 1 bit(2^1 = 2, 2^2 = 4, and so on) and thats how the others were made. and if so would it be done by binary 1's and 0's for each bit?
and would this be a way to get a bit value?
Function GETBIT(BYTE, BIT)
select bit
case 1
exitfunction (BYTE & 15)
endcase
case 2
Exitfunction ((BYTE & 15) / 2)
endcase
case 3
exitfunction ((BYTE & 15) / 4)
endcase
case 4
exitfunction ((BYTE & 15) / 6)
endcase
case 5
exitfunction ((BYTE & 15) / 8)
endcase
case 6
exitfunction ((BYTE & 15) / 10)
endcase
case 7
exitfunction ((BYTE & 15) / 12)
endcase
case 8
exitfunction ((BYTE & 15) / 14)
endcase
endselect
endfunction
Just wondering if it was possible to also
New Site! Check it out \/