How to do cast(ubyte[4])some_uint in D1?

2011-06-02 Thread Nick Sabalausky
In D2, I can treat a uint as an array of ubytes by doing this: uint num = /+...whatever...+/; ubyte[] = cast(ubyte[4])num; How do I do that in D1? IIRC, D1 requires an explicit slice operator to convert from a static-array to a slice/dynamic-array, so I tried this: ubyte[] =

Re: How to do cast(ubyte[4])some_uint in D1?

2011-06-02 Thread bearophile
Nick Sabalausky: In D2, I can treat a uint as an array of ubytes by doing this: uint num = /+...whatever...+/; ubyte[] = cast(ubyte[4])num; How do I do that in D1? Using a union is probably the safest way: union Uint2Ubyte { uint u; ubyte[4] b; } By the way, this of type

Re: How to do cast(ubyte[4])some_uint in D1?

2011-06-02 Thread Timon Gehr
Nick Sabalausky: In D2, I can treat a uint as an array of ubytes by doing this: uint num = /+...whatever...+/; ubyte[] = cast(ubyte[4])num; How do I do that in D1? Using a union is probably the safest way: union Uint2Ubyte { uint u; ubyte[4] b; } By the way, this of type

Re: How to do cast(ubyte[4])some_uint in D1?

2011-06-02 Thread Steven Schveighoffer
On Thu, 02 Jun 2011 05:35:40 -0400, Nick Sabalausky a@a.a wrote: In D2, I can treat a uint as an array of ubytes by doing this: uint num = /+...whatever...+/; ubyte[] = cast(ubyte[4])num; How do I do that in D1? IIRC, D1 requires an explicit slice operator to convert from a static-array

Re: How to do cast(ubyte[4])some_uint in D1?

2011-06-02 Thread Nick Sabalausky
Timon Gehr timon.g...@gmx.ch wrote in message news:is7ojo$2ggv$1...@digitalmars.com... Nick Sabalausky: In D2, I can treat a uint as an array of ubytes by doing this: uint num = /+...whatever...+/; ubyte[] = cast(ubyte[4])num; How do I do that in D1? Using a union is probably the safest

Re: How to do cast(ubyte[4])some_uint in D1?

2011-06-02 Thread Nick Sabalausky
Nick Sabalausky a@a.a wrote in message news:is8qu8$1cq3$1...@digitalmars.com... Timon Gehr timon.g...@gmx.ch wrote in message news:is7ojo$2ggv$1...@digitalmars.com... Nick Sabalausky: In D2, I can treat a uint as an array of ubytes by doing this: uint num = /+...whatever...+/; ubyte[] =