why does Serial.read return int?

the function def returns an int, but the function actually returns an unsigned char (at least when you care about it, when theres nothing to read i guess you get the full int). shouldnt this return an unsigned char all the time? save some memory?

int serialRead() { // if the head isn't ahead of the tail, we don't have any characters if (rx_buffer_head == rx_buffer_tail) { return -1; } else { unsigned char c = rx_buffer[rx_buffer_tail]; rx_buffer_tail = (rx_buffer_tail + 1) % RX_BUFFER_SIZE; return c; } }

It needs at least one extra bit to return all the possible values in an 8 bit byte, plus return a -1 if it has nothing to return. This means a minimum of 16 bits, which is an int.

-j