Re: Best way in D2 to rotate a ubyte[4] array

2011-03-10 Thread spir
On 03/10/2011 11:01 PM, bearophile wrote: While creating the rotation code I have found two things I don't understand. Maybe some of you is able to help me understand. This version of the code: union Four { uint u; ubyte[4] a; } void main() { Four f; asm { rol f.u

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-10 Thread bearophile
While creating the rotation code I have found two things I don't understand. Maybe some of you is able to help me understand. This version of the code: union Four { uint u; ubyte[4] a; } void main() { Four f; asm { rol f.u, 8; } } DMD 2.052 gives this error, do you

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread Andrew Wiley
On Wed, Mar 9, 2011 at 7:25 PM, U2 fan wrote: > == Quote from bearophile (bearophileh...@lycos.com)'s article >> Tom: >> > What is the most efficient way of implement a rotation of ubyte[4] array? >> > >> > By rotation I mean: rotateRight([1, 2, 3, 4]) -> [4, 1, 2, 3] >> Two versions, I have done

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread U2 fan
== Quote from bearophile (bearophileh...@lycos.com)'s article > Tom: > > What is the most efficient way of implement a rotation of ubyte[4] array? > > > > By rotation I mean: rotateRight([1, 2, 3, 4]) -> [4, 1, 2, 3] > Two versions, I have done no benchmarks so far: > import std.c.stdio: printf; >

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread spir
On 03/10/2011 12:55 AM, Jonathan M Davis wrote: I don't know of anything more efficient than: >ubyte[4] bytes = [1,2,3,4]; >bytes = bytes[$-1] ~ bytes[0..$-1]; // Rotate left I'm stunned that this works. I'd even consider reporting it as a bug. You're concatenating a ubyte[] ont

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread Kai Meyer
On 03/09/2011 04:25 PM, bearophile wrote: Tom: What is the most efficient way of implement a rotation of ubyte[4] array? By rotation I mean: rotateRight([1, 2, 3, 4]) -> [4, 1, 2, 3] Two versions, I have done no benchmarks so far: import std.c.stdio: printf; union Four { ubyte[4] a;

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread Jonathan M Davis
On Wednesday, March 09, 2011 15:35:29 Kai Meyer wrote: > On 03/09/2011 03:41 PM, Tom wrote: > > What is the most efficient way of implement a rotation of ubyte[4] array? > > > > By rotation I mean: rotateRight([1, 2, 3, 4]) -> [4, 1, 2, 3] > > > > TIA, > > Tom; > > I don't know of anything more

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread Tom
El 09/03/2011 20:25, bearophile escribió: Tom: What is the most efficient way of implement a rotation of ubyte[4] array? By rotation I mean: rotateRight([1, 2, 3, 4]) -> [4, 1, 2, 3] Two versions, I have done no benchmarks so far: import std.c.stdio: printf; union Four { ubyte[4] a;

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread Kai Meyer
On 03/09/2011 03:41 PM, Tom wrote: What is the most efficient way of implement a rotation of ubyte[4] array? By rotation I mean: rotateRight([1, 2, 3, 4]) -> [4, 1, 2, 3] TIA, Tom; I don't know of anything more efficient than: ubyte[4] bytes = [1,2,3,4]; bytes = bytes[$-1] ~ bytes[0..

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread bearophile
Tom: > What is the most efficient way of implement a rotation of ubyte[4] array? > > By rotation I mean: rotateRight([1, 2, 3, 4]) -> [4, 1, 2, 3] Two versions, I have done no benchmarks so far: import std.c.stdio: printf; union Four { ubyte[4] a; uint u; } void showFour(Four f) {