Int to float?
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Mar 5 12:32:19 PST 2015
On Thursday, 5 March 2015 at 20:21:18 UTC, badlink wrote:
> On Thursday, 5 March 2015 at 20:16:55 UTC, anonymous wrote:
>> On Thursday, 5 March 2015 at 20:03:09 UTC, Benjamin Thaut
>> wrote:
>>> int someValue = 5;
>>> float sameBinary = *(cast(float*)cast(void*)&someValue);
>>
>> The cast(void*) isn't necessary.
>
> Actually even the cast is unecessary, just use a uniform.
>
> union N {
> int i;
> float f;
> }
>
> http://dpaste.dzfl.pl/58b6eddcf725
That's not really simpler, though.
More information about the Digitalmars-d-learn
mailing list