On 11/21/14 1:55 PM, Marco Leise wrote:
Am Wed, 19 Nov 2014 18:20:24 +0000
schrieb "Marc Schütz" <[email protected]>:
I'd say length being unsigned is fine. The real mistake is that
the difference between two unsigned values isn't signed, which
would be the most "correct" behaviour.
Now take my position where I explicitly write code relying
on the fact that `bigger - smaller` yields correct results.
uint bigger = uint.max;
uint smaller = 2;
if (bigger > smaller)
{
auto added = bigger - smaller;
// Now 'added' is an int with the value -3 !
}
else
{
auto removed = smaller - bigger;
}
Interesting insight. Thanks for the many analytical examples you're
giving in this thread. -- Andrei