Write your question here.
Hello,
while compiling the below code, I get this strange ( to me ) warning.
warning: comparison of unsigned expression >= 0 is always true
1 2 3 4 5 6 7
Put the code you need help with here.
unsignedint myvalue = 3;
if( ( my value >= 0 ) && ( myvalue <= 8 ) )
{ dosomething(); }
but this works ok :
if( ( my value ) && ( myvalue <= 8 ) )
{ dosomething(); }
If myvalue is unsigned (so it can never be less than 0), then the test myvalue >= 0 will always be true, so it's pointless. You only need the myvalue <= 8 part. In the second piece of code, just writing myvalue is equivalent to writing myvalue != 0, which is obviously a different and potentially useful comparison.