March 06, 2015
On Friday, 6 March 2015 at 00:57:16 UTC, Ola Fosheim Grøstad wrote:
> On Thursday, 5 March 2015 at 23:50:28 UTC, Jesse Phillips wrote:
>> I think I read somewhere you don't want to use unions like this, but I think it is more because you generally don't want to reinterpret bits.
>
> It is non-portable, since some hardware architectures may use different representations (e.g. different byte order on int and float).

Then maybe use std.bitmanip?

  import std.bitmanip;
  int i = 5;
  float f = bigEndianToNative!float(nativeToBigEndian(i));
  // or float f = littleEndianToNative!float(nativeToLittleEndian(i));
1 2
Next ›   Last »