NeoTechni Well-Known Member Licensed User Longtime User Jul 10, 2013 #1 Could we get some please? I like my bytes to go from 0 to 255!
Erel B4X founder Staff member Licensed User Longtime User Jul 11, 2013 #3 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: Code: Copy Dim Unsigned(b As Byte) As Int Return Bit.And(0xFF, b) End Sub Code: Copy 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.
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: Code: Copy Dim Unsigned(b As Byte) As Int Return Bit.And(0xFF, b) End Sub Code: Copy 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.