www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - ubyte array to uint?

reply "Gan" <avisaria me.com> writes:
Is there a simple way of conversion? Something like:
uint length = to!uint(buffer[0 .. 4]);

Right now I have:
uint length = *cast(uint*)buffer[0 .. 4].ptr;

Which I'm not entirely sure is the correct way to do that.
Feb 05 2015
parent "weaselcat" <weaselcat gmail.com> writes:
On Friday, 6 February 2015 at 05:18:45 UTC, Gan wrote:
 Is there a simple way of conversion? Something like:
 uint length = to!uint(buffer[0 .. 4]);

 Right now I have:
 uint length = *cast(uint*)buffer[0 .. 4].ptr;

 Which I'm not entirely sure is the correct way to do that.
Hi, check out std.bitmanip.read
Feb 05 2015