Quote Originally Posted by tuli View Post
why doesnt the following program work as expected:
Two guidelines that can help to prevent these kinds of errors are:
- Don't use magic numbers. If you use a const variable for the value 0xff, you make the type of that variable explicit.
- Don't mix signed and unsigned arithmetics. Signed values will get promoted to unsigned, which can cause unexpected results.