Movement against float.init being nan

Dave P. dave287091 at gmail.com
Tue Aug 23 21:40:11 UTC 2022


On Tuesday, 23 August 2022 at 21:24:10 UTC, Ali Çehreli wrote:
> On 8/23/22 13:44, Dave P. wrote:
> > On Friday, 19 August 2022 at 13:42:58 UTC, Hipreme wrote:
> >> [...]
>
> > will have completely different initial values
>
> Although C does not initialize variables, sometimes both C and 
> D floats can have the same exact bit pattern.
>
> > despite being syntactically identical!
>
> C and D are different languages.
>

This is a struct defined in C being used in D via ImportC.

> >      writeln(f_d); // Foo(nan)
>
> That will always be the case.
>
> >      writeln(f_c); // Foo(0)
>
> And yes, 0 happens to be a valid garbage value.

The default value for a struct imported via importC is all bits 
0. This is not a “garbage value”.




More information about the Digitalmars-d mailing list