[Gambas-user] unsigned int datatype for external function

Benoît Minisini g4mba5 at gmail.com
Sun Jun 10 20:31:23 CEST 2018


Le 10/06/2018 à 17:38, Demosthenes Koptsis a écrit :
> hello,
> 
> i want to use an unsigned int in external function, which gambas 
> datatype should i use?
> 
> Integer or Long?
> 
> The range of values is 0 to 4,294,967,295
> 
> 
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> .

You must use the Integer datatype.

Then if you want to get the real unsigned integer value, as there is no 
UnsignedInteger datatype in Gambas (sorry for that), you have to do this 
trick:

Public Sub UnsignedIntegerToLong(X As Integer) As Long

   Return CLong(X) And (Lsl(1, 32) - 1)

End

Public Sub LongToUnsignedIntegerToLong(X As Integer) As Integer

   Return X

End

-- 
Benoît Minisini


More information about the User mailing list