Movement against float.init being nan

kdevel kdevel at vogtner.de
Thu Aug 25 17:14:04 UTC 2022


On Thursday, 25 August 2022 at 16:39:14 UTC, Walter Bright wrote:
> [...]
> If you aren't looking at your output, then why are you 
> calculating the value?

To make decisions?

    double compute_pop ()
    {
       double pop;
       // forgot to implement the computation
       // or ran into a nan by an instable computation
       pop = sqrt (-1.);
       pop += 0.;
       return pop;
    }

    int main ()
    {
       auto pop = compute_pop ();
       if (pop < .5)
          writeln ("It will not rain.");
       else
          writeln ("It will rain.");
       return 0;
    }


More information about the Digitalmars-d mailing list