Endiannes & Splitting Values
Lodovico Giaretta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jul 7 01:21:53 PDT 2016
On Thursday, 7 July 2016 at 08:14:40 UTC, Gary Willoughby wrote:
>
> What about something like:
>
> import std.stdio;
>
> union Value
> {
> ulong full;
>
> static struct Bits
> {
> uint high;
> uint low;
> }
>
> Bits bits;
> alias bits this;
>
> this(ulong value)
> {
> this.full = value;
> }
> }
>
> void main(string[] args)
> {
> auto value = Value(77309411348);
>
> writefln("%s, (%b)", value.high, value.high);
> writefln("%s, (%b)", value.low, value.low);
> writefln("%s, (%b)", value.full, value.full);
> }
Hi,
Are you sure that this works in both big-endian and little-endian
systems?
More information about the Digitalmars-d-learn
mailing list