a way to specily floating-point numbers as bit patters

Honey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 9 09:27:47 PDT 2017


On Friday, 9 June 2017 at 16:07:36 UTC, ketmar wrote:
> one of my calculated values is `-0.166667`, which has 
> bit-pattern of 0xBE2AAAB7.
> now, let's say i want to use this number in my code:
>
> 	float v = -0.166667f;
> 	writefln("%f 0x%08X", v, *cast(uint*)&v);
>
> oooops. "-0.166667 0xBE2AAAC1". it's not the same! (and yes, it 
> matters).

Try -0.16666685f.


More information about the Digitalmars-d-learn mailing list