Hello, new to the forum and b4a (using it for a trainee work), I'm trying to use the RAF library to read bytes from a stream and turn it into an int (simulated with the dummy) but can't wrap my head around it's output.
At first i thought my mistake was not adding "" while assigning value to dummy, but even with those i can't uderstand the output (second column in the comments)
How does exactly the conversion and assignment work?
Thanks for your time and help, i'm sure i'll soon feel VERY stupid D:
PS: Off topic, but how can i get an array or string of 0 and 1 from one of those bytes? I need to manipulate it bit by bit
At first i thought my mistake was not adding "" while assigning value to dummy, but even with those i can't uderstand the output (second column in the comments)
B4X:
Sub calc
Dim Dummy(11) As Byte
Dim tmp As Int
Dummy(0) = 00000000 'prints 0 0
Dummy(1) = 11111111 'prints 199 199
Dummy(2) = 00100000 'prints 0 160
Dummy(3) = 01000000 'prints 0 64
Dummy(4) = 10000000 'prints 128 128
Dummy(5) = 00000001 'prints 1 1
Dummy(6) = 00000010 'prints 8 10
Dummy(7) = 00000100 'prints 64 100
Dummy(8) = 00001000 'prints 0 232
Dummy(9) = 00010000 'prints 0 16
Dummy(10) = 01000000 'prints 0 64
Dim RAF As RandomAccessFile
RAF.Initialize3(Dummy,False)
For i = 0 To Dummy.Length
tmp=RAF.ReadUnsignedByte(i) ' should go from 0 to 255
Msgbox(tmp,i)
Next
End Sub
How does exactly the conversion and assignment work?
Thanks for your time and help, i'm sure i'll soon feel VERY stupid D:
PS: Off topic, but how can i get an array or string of 0 and 1 from one of those bytes? I need to manipulate it bit by bit
Last edited: