Wish unsigned variable types

Erel

B4X founder
Staff member
Licensed User
Longtime User
I completely understand this request.

However Basic4android data types are based on Java data types which are signed. Adding a new "primitive" type such as an unsigned byte is not impossible however it may be problematic.

Once you fully understand how to work with the signed byte you will see that it doesn't really matter whether it is signed or not.

You can create a simple method that converts a byte to an unsigned value:
B4X:
Dim Unsigned(b As Byte) As Int
 Return Bit.And(0xFF, b)
End Sub

B4X:
Dim b As Byte = 200
Log(Unsigned(b)) 'prints 200

Only when you try to "see" the value you will see that it is signed and not unsigned.
 
Top