A Philosophy of Software Design
Walter Bright
newshound2 at digitalmars.com
Sun Jun 28 02:15:37 UTC 2026
On 6/27/2026 5:13 PM, Forum User wrote:
> On Saturday, 27 June 2026 at 19:48:44 UTC, Walter Bright wrote:
>> [...]
>> It behaves much like the floating point NaN value, which is a generally
>> misunderstood and underappreciated.
>
> NaNs increase hidden complexity and require more source code
> (i.e. increase source code complexity) in order to do things right:
>
> auto t = (t2);
> if (t < 2.0)
> writeln ("met the climate target");
> else
> writeln ("failed to meet the climate target");
The reader would want to know how well the number met the target, or how badly
it failed:
```d
if (t < 2.0)
writeln ("%g met the climate target", t);
else
writeln ("%g failed to meet the climate target", t);
```
Besides, getting a NaN result is always better than getting an arbitrary number
with no clue whether it is valid or a bug.
More information about the Digitalmars-d
mailing list