Movement against float.init being nan
    Nick Treleaven 
    nick at geany.org
       
    Sat Aug 20 13:06:49 UTC 2022
    
    
  
On Saturday, 20 August 2022 at 12:53:28 UTC, Adam D Ruppe wrote:
> ---
> void main() {
>         float f = 7.0;
>         f /= 0;
>         import core.stdc.stdio;
>         printf("%d\n", *cast(int*)&f);
>         if(f is float.init)
>                 printf("nan\n");
> }
> ---
>
> That's a different nan than the float.init pattern. I don't 
> know if you can start with a float.init and come up with a 
> different pattern though, but i expect you can.
Thanks. The above is infinity though.
	f = 1.0;
	f /= 0;
	assert(f is f.infinity);
This produces a different NaN:
	float f = 0;
	f /= 0;
	assert(f is f.nan); //fails
    
    
More information about the Digitalmars-d
mailing list