A Philosophy of Software Design
Dom Disc
dominikus at scherkl.de
Mon May 25 12:14:08 UTC 2026
On Sunday, 24 May 2026 at 04:10:31 UTC, Walter Bright wrote:
> 3. Invalid code nodes are replaced with "Error" nodes. This
> worked far better than I anticipated. No exceptions are thrown.
> It also behaves like NaN.
This is why I always suggested a NaN value for all types. For
signed integers the unfortunate T.min (0x80..00) which has no
positive counterpart is the perfect candidate for NaN. Unsigned
types doesn't have such a good candidate - for sure, most
calculations that try to prevent overflows are very unlikely to
return 0xFF..FF as result, nevertheless this is a valid result.
So defining T.max as NaN is possible but ugly.
More information about the Digitalmars-d
mailing list