The below code prints 1, why?
Compiled on ESP32/Arduino sketch, ver 1.8.3
void setup() {
// put your setup code here, to run once:
Serial.begin(38400);
char b = -1;
char c = 1;
Serial.println(b>c);
}
void loop() {
// put your main code here, to run repeatedly:
}
There are no guarantees about the signedness and size (other than it being at least 8 bits) of the char type. It may vary from one architecture to another. On the ESP32, char is an unsigned 8 bit type. On the AVR architecture, it's a signed 8 bit type.
I recommend only using char to store characters. If you need a signed 8 bit type, use int8_t.