floats default to NaN... why?

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Apr 14 08:35:01 PDT 2012


On 4/14/12, F i L <witte2008 at gmail.com> wrote:
> This is exactly what I'm trying to get at.

Anyway it's not all bad news since we can use a workaround:

struct Float {
    float payload = 0.0;
    alias payload this;
}

void main() {
    Float x;  // acts as a float, is initialized to 0.0
}

Not pretty, but it comes in handy.


More information about the Digitalmars-d-learn mailing list