disabling unary "-" for unsigned types

Steven Schveighoffer schveiguy at yahoo.com
Tue Feb 16 19:51:02 PST 2010


Daniel Keep Wrote:

> 
> Since everyone seemed to miss the point I was trying to make, I'll be
> more explicit.
> 
> My point was that it's all very well to say "you should know X" and you
> can even be totally right about that, but it doesn't mean behaviour
> based on X is necessarily intuitive or desirable.
> 
> Walter specifically said that "I don't feel that 2s-complement
> arithmetic is in any way an advanced programming topic".  I agree.  I
> was trying to point out that even very experienced people who would
> surely know what's going on in the hardware can get it wrong.

I agree with this.  However, even though experienced programmers can write 2s complement math with bugs, in this particular case, there is *no* correct way to do it.  So it's impossible to get it right :)

Any opposing view would have to include what obtaining the unsigned negation of an unsigned value is useful for.  And literals don't count because they're easily expressed otherwise :)

-Steve



More information about the Digitalmars-d mailing list