On Sat, Apr 10, 2010 at 02:55:36PM -0400, bearophile wrote: > Time ago I have even suggested to disallow bitwise ops when one or both > operands are signed...
I understand the position, but I don't advocate it just because I think it would be annoying and not give much of a benefit. Consider the following: for(int a = -10; a < 10; a++) writeln(a&1 ? "odd" : "even"); I'd just be annoyed if I had to cast a to uint just to do that. Note that it works on negative numbers too, so it isn't strictly wrong to do it on signed ints. I use this when doing stripes on outputted tables and stuff like that. a % 2 does the same thing, so this specific case isn't a big deal, but I still tend to type &1 rather than %2 out of habit (this kind of thing used to make a real speed difference back in the DOS days when I learned it all!) -- Adam D. Ruppe http://arsdnet.net