float init 0 request

Kapendev alexandroskapretsos at gmail.com
Fri Aug 14 16:23:18 UTC 2026


On Friday, 14 August 2026 at 05:57:55 UTC, ABrightLight wrote:
> Hello. I understand this subject's been discussed a number of 
> times before, but I'd like to throw in my reasoning for why it 
> would benefit us more for floats to initialize to 0 than NaN.

I'm in the `float.init = 0` team only because I know most people 
prefer the default to be `float.init = 0`.
Arguments like "defining errors out of existence" or that NaN 
silently propagates are missing the point of NaN or what the main 
issue here really is.
What is the main issue?
It's who is going to write five extra characters.

```d
float a = 0.0f;     // Zero fans :(
float a = float.nan // NaN fans :(
```

I never care about the default float value because I usually 
write:

```d
auto number = 0.0f
```

No issue. I defined the error out of existence! Feels good to say 
that line.
Only issue remaining are structs and generic code.
Those two I get that it might be annoying to set default values 
only for floats.



More information about the Digitalmars-d mailing list