Re: why is the default floating point value NAN ?

2018-10-17 Thread Dennis via Digitalmars-d-learn

On Wednesday, 17 October 2018 at 15:51:21 UTC, Codifies wrote:
okay I should have carried on reading the blog, its so 
uninitialized values stick out when debugging...


Indeed, the initial value is not supposed to be useful, it's 
there because dealing with garbage memory when forgetting to 
initialize a variable is hard to debug. That's also why 
characters are initialized to 0xFF. Unfortunately, (associative) 
arrays and integers initialize to an empty array and 0 
respectively by a lack of an 'invalid' value.


These are often useful initial values, so people who didn't know 
about / didn't agree with that philosphy started using default 
initialization. Even the 'Count fequencies of all 2-tuples' 
example on the dlang homepage uses an uninitialized associative 
array.


Re: why is the default floating point value NAN ?

2018-10-17 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 17 October 2018 at 15:48:16 UTC, Codifies wrote:

I'd have thought it ought to be 0.0 ?

So far I seen carefully considered and sensible reasons for 
doing things in D, so why NAN ?


You are supposed to initialize your own variables explicitly. NaN 
is a somewhat easy way to indicate that you forgot to do that.


Re: why is the default floating point value NAN ?

2018-10-17 Thread Codifies via Digitalmars-d-learn

On Wednesday, 17 October 2018 at 15:48:16 UTC, Codifies wrote:

I'd have thought it ought to be 0.0 ?

So far I seen carefully considered and sensible reasons for 
doing things in D, so why NAN ?


okay I should have carried on reading the blog, its so 
uninitialized values stick out when debugging...


why is the default floating point value NAN ?

2018-10-17 Thread Codifies via Digitalmars-d-learn

I'd have thought it ought to be 0.0 ?

So far I seen carefully considered and sensible reasons for doing 
things in D, so why NAN ?