convert ubyte[k..k + 1] to int
Luis Panadero Guardeño
luis.panadero at gmail.com
Mon May 21 03:26:25 PDT 2012
ref2401 wrote:
> i have an array of ubytes. how can i convert two adjacent ubytes
> from the array to an integer?
>
> pseudocode example:
> ubyte[5] array = createArray();
> int value = array[2..3];
>
> is there any 'memcpy' method or something else to do this?
Try to use littleEndianToNative or bigEndianToNative, but you should check
the endianes of the data that you desire convert to a int.
For example:
ubyte[5] array = createArray();
int value = littleEndianToNative!int(array);
// or:
// int value = bigEndianToNative!int(array);
--
I'm afraid that I have a blog: http://zardoz.es
More information about the Digitalmars-d-learn
mailing list