On Monday, 22 August 2016 at 04:37:50 UTC, stunaep wrote:
I made a union to convert between int bits and floats, but the values are coming out wrong sometimes. This is working without issue in other languages so I'm really stumped. Here's an example:

union test { int i; float f; }
test t = { i : 0x7fb00000};
float t2 = t.f;//int bits 0x7fb00000 as float
test t3 = { f : t2 };
writefln("%x", t3.i);//prints 7ff00000 NOT 0x7fb00000

Ok on linux, 0x7fb00000 is written, I tested under linux x86_64 with latest dmd beta, ldc and also gdc.

Which compiler and version do you use ?
Which OS and archi ?

Reply via email to