Int to float?

badlink via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 5 12:21:16 PST 2015


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


More information about the Digitalmars-d-learn mailing list