Simple Q about unsigned integers

When you subtract a quantity from an unsigned integer such that it would become negative, am I correct in thinking it "loops around"?

So, subtracting 1 from zero=255?

Sorry for the noob quotient inherent in this question. :confused:

(deleted)

So, subtracting 1 from zero=255?

Try it with a byte, which is, of course an unsigned integer (but not an unsigned int)

Try this

  byte byte1 = 0;
  byte1--;
  Serial.println(byte1);
  byte byte2 = 0;
  byte2 = byte2 - 1;
  Serial.println(byte2);
  byte byte3 = 0;
  Serial.println(byte3 - 1);

Before running it predict the results

jeric_synergy:
So, subtracting 1 from zero=255?

That would be true if you are using a byte which is an unsigned 8 bit value

An unsigned int is a 16 bit value so 0 - 1 gives 65535

...R