On Tuesday, 6 February 2018 at 07:15:33 UTC, Walter Bright wrote:
The thing is, when there are mixed integer sizes and
signedness, there is no intuitive and correct solution. Each
set of rules comes with its own set of cases where there are
unintuitive behaviors.
So, why doing any promotion at all?
If two different types are used in an arithmetic operation,
the larger of those two types should be the result type.
And if the result would be truncated in some way, return NAN.
Every type should have a NAN value.
For the signed types the extra useless .min is a perfect
candidate for a NAN.
That allows -x to always be of the same type as x, which I think
is a good thing(tm).
Fortunately, in D is't absolutely easy to define just that kind
of types
that fullfill all these requirements. Its about 100 LOC.
I call them sbyte, sword, sint and slong which are even better
names than the original ones (because they directly indicate that
they are signed and match the unsigned ones).
So I never again bother with the completely nuts builtin signed
types.