Ezra Nugroho wrote:
> I probably should say integers that I can modify with bitwise operators
> comfortably without changing the signs. The problem is that people may
> want to do comparison after doing bitwise operations. If the sign is
> changed, the comparison will not be valid, right?
>
> That's why I want to stay within the positive range.
You just don't care about signedness:
mike@honeybadger:~/development/testimonials$ ./un_or_signed
-1 4294967295 4294967295 -1 EQUAL
mike@honeybadger:~/development/testimonials$ cat un_or_signed.c
#include <stdio.h>
int main(int argc, char *argv[])
{
signed i1 = -1;
unsigned i2 = -1;
printf("%d %u %u %d %s\n", i1, i2, i1, i2, i1==i2?"EQUAL":"DIFFER");
return 0;
}
Regards,
--
Michael - <mike(@)php.net> http://dev.iworks.at/ext-http/http-functions.html.gz