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
On Thursday, 17 May 2012 at 04:16:10 UTC, Andrew Wiley wrote:
On Wed, May 16, 2012 at 11:07 PM, H. S. Teoh
hst...@quickfur.ath.cx wrote:
Do unions suffer from this problem? Could this prevent
alignment
problems:
short bytesToShort(ubyte[] b)
in { assert(b.length==2); }
On Thursday, 17 May 2012 at 07:07:58 UTC, Roman D. Boiko wrote:
And what about the following code:
// This implementation is optimized for speed via swapping
endianness in-place
pure immutable(C)[] fixEndian(C, Endian blobEndian =
endian)(ubyte[] blob) if(is(CharTypeOf!C))
{
import
On 05/17/12 10:15, Roman D. Boiko wrote:
On Thursday, 17 May 2012 at 07:07:58 UTC, Roman D. Boiko wrote:
And what about the following code:
// This implementation is optimized for speed via swapping
endianness in-place
pure immutable(C)[] fixEndian(C, Endian blobEndian =
endian)(ubyte[]
On Thursday, 17 May 2012 at 08:39:21 UTC, Artur Skawina wrote:
On 05/17/12 10:15, Roman D. Boiko wrote:
I mean, is it safe (assuming that we are allowed to mutate
blob, and its length is a multiple of C.sizeof)?
I do casting from ubyte[] to C[].
Only if C.ptr ends up properly aligned. There
On 05/17/12 10:47, Roman D. Boiko wrote:
On Thursday, 17 May 2012 at 08:39:21 UTC, Artur Skawina wrote:
On 05/17/12 10:15, Roman D. Boiko wrote:
I mean, is it safe (assuming that we are allowed to mutate blob, and its
length is a multiple of C.sizeof)?
I do casting from ubyte[] to C[].
On 05/17/12 11:36, Artur Skawina wrote:
assert(cast(size_t)data.ptr%data.alignof==0);
This assert can be easily triggered eg by doing
blob[1..$-4]; blob.assumeSafeAppend(); ++blob.length;
auto data = cast(C[]) blob;
Umm, that was meant to be:
blob = blob[1..$-4];
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?
On Wed, 16 May 2012 15:24:33 +0100, ref2401 refacto...@gmail.com 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
On Wednesday, May 16, 2012 17:03:44 Regan Heath wrote:
On Wed, 16 May 2012 15:24:33 +0100, ref2401 refacto...@gmail.com 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
On Wednesday, 16 May 2012 at 18:47:55 UTC, Jonathan M Davis wrote:
As long as you're going from big endian to little endian,
std.bitmanip.bigEndianToNative will do the conversion fairly
easily, but if
they're in little endian, then the nasty casting is the way to
go.
- Jonathan M Davis
On Thursday, May 17, 2012 02:32:55 Robert DaSilva wrote:
On Wednesday, 16 May 2012 at 18:47:55 UTC, Jonathan M Davis wrote:
As long as you're going from big endian to little endian,
std.bitmanip.bigEndianToNative will do the conversion fairly
easily, but if
they're in little endian, then
On Wed, May 16, 2012 at 11:03 AM, Regan Heath re...@netmail.co.nz wrote:
On Wed, 16 May 2012 15:24:33 +0100, ref2401 refacto...@gmail.com 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 =
On Wed, May 16, 2012 at 10:25:51PM -0500, Andrew Wiley wrote:
On Wed, May 16, 2012 at 11:03 AM, Regan Heath re...@netmail.co.nz wrote:
On Wed, 16 May 2012 15:24:33 +0100, ref2401 refacto...@gmail.com wrote:
i have an array of ubytes. how can i convert two adjacent ubytes from the
array
On Wed, May 16, 2012 at 11:07 PM, H. S. Teoh hst...@quickfur.ath.cx wrote:
On Wed, May 16, 2012 at 10:25:51PM -0500, Andrew Wiley wrote:
On Wed, May 16, 2012 at 11:03 AM, Regan Heath re...@netmail.co.nz
wrote:
On Wed, 16 May 2012 15:24:33 +0100, ref2401 refacto...@gmail.com
wrote:
15 matches
Mail list logo