Re: ubytes to ulong problem

2013-12-22 Thread Charles Hixson
On 12/22/2013 02:22 AM, Ali Çehreli wrote: On 12/22/2013 01:04 AM, Charles Hixson wrote: > Nice, but the block is longer than 8 bytes, so I should use a "for (i = > n; i < n + 8; i++)" rather than a foreach, and index off of i. Makes sense. That reminded me of the Phobos function that does exac

Re: ubytes to ulong problem

2013-12-22 Thread John Colvin
On Sunday, 22 December 2013 at 03:57:38 UTC, Ali Çehreli wrote: On 12/21/2013 05:44 PM, Charles Hixson wrote: On 12/21/2013 03:52 PM, Ali Çehreli wrote: On 12/21/2013 03:13 PM, John Colvin wrote: > Ideally the compiler will optimise your version to be fast, > but you may > find you get better

Re: ubytes to ulong problem

2013-12-22 Thread Ali Çehreli
On 12/22/2013 01:04 AM, Charles Hixson wrote: > Nice, but the block is longer than 8 bytes, so I should use a "for (i = > n; i < n + 8; i++)" rather than a foreach, and index off of i. Makes sense. That reminded me of the Phobos function that does exactly what you want. Have you considered std.

Re: ubytes to ulong problem

2013-12-22 Thread Charles Hixson
On 12/21/2013 07:57 PM, Ali Çehreli wrote: On 12/21/2013 05:44 PM, Charles Hixson wrote: On 12/21/2013 03:52 PM, Ali Çehreli wrote: On 12/21/2013 03:13 PM, John Colvin wrote: > Ideally the compiler will optimise your version to be fast, but you may > find you get better performance by doing

Re: ubytes to ulong problem

2013-12-21 Thread Ali Çehreli
On 12/21/2013 05:44 PM, Charles Hixson wrote: On 12/21/2013 03:52 PM, Ali Çehreli wrote: On 12/21/2013 03:13 PM, John Colvin wrote: > Ideally the compiler will optimise your version to be fast, but you may > find you get better performance by doing the bit manipulations eplicitly: Assuming tha

Re: ubytes to ulong problem

2013-12-21 Thread Charles Hixson
On 12/21/2013 03:52 PM, Ali Çehreli wrote: On 12/21/2013 03:13 PM, John Colvin wrote: > Ideally the compiler will optimise your version to be fast, but you may > find you get better performance by doing the bit manipulations eplicitly: Assuming that the program needs to support only big endia

Re: ubytes to ulong problem

2013-12-21 Thread John Colvin
On Saturday, 21 December 2013 at 23:52:05 UTC, Ali Çehreli wrote: On 12/21/2013 03:13 PM, John Colvin wrote: > Ideally the compiler will optimise your version to be fast, but you may > find you get better performance by doing the bit manipulations eplicitly: Assuming that the program needs to s

Re: ubytes to ulong problem

2013-12-21 Thread Ali Çehreli
On 12/21/2013 03:13 PM, John Colvin wrote: > Ideally the compiler will optimise your version to be fast, but you may > find you get better performance by doing the bit manipulations eplicitly: Assuming that the program needs to support only big endian and little endian systems (i.e. excluding s

Re: ubytes to ulong problem

2013-12-21 Thread Charles Hixson
On 12/21/2013 02:31 PM, ponce wrote: On Saturday, 21 December 2013 at 22:29:59 UTC, ponce wrote: On Saturday, 21 December 2013 at 22:22:09 UTC, Charles Hixson wrote: I was planning to ask if there were a better way to do this, but instead I need to ask what's my mistake? For some reason, if cal

Re: ubytes to ulong problem

2013-12-21 Thread John Colvin
On Saturday, 21 December 2013 at 22:22:09 UTC, Charles Hixson wrote: I was planning to ask if there were a better way to do this, but instead I need to ask what's my mistake? For some reason, if called with an uninitialized ubyte array, and an index of 0, it returns a value of 8, even though all

Re: ubytes to ulong problem

2013-12-21 Thread ponce
On Saturday, 21 December 2013 at 22:29:59 UTC, ponce wrote: On Saturday, 21 December 2013 at 22:22:09 UTC, Charles Hixson wrote: I was planning to ask if there were a better way to do this, but instead I need to ask what's my mistake? For some reason, if called with an uninitialized ubyte array,

Re: ubytes to ulong problem

2013-12-21 Thread ponce
On Saturday, 21 December 2013 at 22:22:09 UTC, Charles Hixson wrote: I was planning to ask if there were a better way to do this, but instead I need to ask what's my mistake? For some reason, if called with an uninitialized ubyte array, and an index of 0, it returns a value of 8, even though all