floating point - nan initializers
Ben Hinkle
ben.hinkle at gmail.com
Sun Feb 19 11:46:12 PST 2006
"Dave" <Dave_member at pathlink.com> wrote in message
news:dt85ll$2vis$1 at digitaldaemon.com...
>
> Rational: nan will propogate through an entire calculation if the
> developer
> forgets to initialize a floating point variable.
[snip]
> Maybe I'm wrong.. Opinions?
>
> Thanks,
>
> - Dave
I'm with you that nan initializer is annoying. The archives have some
discussions on the topic - with Walter's replies. My own approach would be
to use 0 initializer, toss 'auto' and introduce that := operator that came
up recently that I talk about every now and then. The benefit of := is that
*you* supply the initialization so the whole issue of worying about the
default initializer is much less common. For example instead of
double x;
and wondering what the initial value is (if any) one writes
x := 0.0;
and you're done. Multiple variables are declared-and-inited using
x := y := z := 0.0;
-Ben
ps. I hope people aren't annoyed by this plug but := is in Cx
http://www.cxlang.org
More information about the Digitalmars-d
mailing list