Android Question Randomaccessfile: Reading unsigned integer

grafsoft

Well-Known Member
Licensed User
Longtime User
Hi,

I am reading an int with the readint method of RandomAccessFile. Now I have a negative integer, but what I need is an unsignedd int. I have trie3d to add different powers of 2, but to no avail.

Thanks for your help!

Peter
 
Using the forumsearch COULD HAVE HELPED. It is working!

Code:
Sub ToUnsigned(b As Byte) As Int
   Return Bit.And(0xFF, b)
End Sub

'check:
Log(Bit.ToHexString(ToUnsigned(0xAA)))
 
Upvote 0
No. But I have a value of -400818176, which is converted into -4.00818176E8

Unsigned should be positive, I think a value of about 7000 should come out.
 
Upvote 0
Still does not work, produces -400818176. I made a little project that does only use this function and added it to this post.
 

Attachments

Upvote 0
Back
Top