Re: Endiannes & Splitting Values

2016-07-07 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 7 July 2016 at 10:48:56 UTC, Lodovico Giaretta wrote: On Thursday, 7 July 2016 at 10:45:12 UTC, Gary Willoughby wrote: On Thursday, 7 July 2016 at 08:21:53 UTC, Lodovico Giaretta wrote: Are you sure that this works in both big-endian and little-endian systems? It shouldn't

Re: Endiannes & Splitting Values

2016-07-07 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 7 July 2016 at 10:45:12 UTC, Gary Willoughby wrote: On Thursday, 7 July 2016 at 08:21:53 UTC, Lodovico Giaretta wrote: Are you sure that this works in both big-endian and little-endian systems? It shouldn't matter. You're just interested in the high and low 4 byte chunks (which

Re: Endiannes & Splitting Values

2016-07-07 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 7 July 2016 at 08:21:53 UTC, Lodovico Giaretta wrote: Are you sure that this works in both big-endian and little-endian systems? It shouldn't matter. You're just interested in the high and low 4 byte chunks (which are to be interpreted as an int) which will return in the

Re: Endiannes & Splitting Values

2016-07-07 Thread Lodovico Giaretta via Digitalmars-d-learn
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) {

Re: Endiannes & Splitting Values

2016-07-07 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 21:44:37 UTC, BitGuy wrote: I'm trying to implement a feistel cipher that'll give the same results regardless of the endianness of the machine it runs on. To make the cipher I need to split a 64bit value into two 32bit values, mess with them, and then put them back

Re: Endiannes & Splitting Values

2016-07-06 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 21:44:37 UTC, BitGuy wrote: I'm trying to implement a feistel cipher that'll give the same results regardless of the endianness of the machine it runs on. To make the cipher I need to split a 64bit value into two 32bit values, mess with them, and then put them back

Re: Endiannes & Splitting Values

2016-07-06 Thread Lodovico Giaretta via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 21:44:37 UTC, BitGuy wrote: I'm trying to implement a feistel cipher that'll give the same results regardless of the endianness of the machine it runs on. To make the cipher I need to split a 64bit value into two 32bit values, mess with them, and then put them back

Endiannes & Splitting Values

2016-07-06 Thread BitGuy via Digitalmars-d-learn
I'm trying to implement a feistel cipher that'll give the same results regardless of the endianness of the machine it runs on. To make the cipher I need to split a 64bit value into two 32bit values, mess with them, and then put them back together. I can think of a few ways to split a 64bit