Regarding u after number

Hello. I was testing adding u after int number in Arduino enviroment. As u specifies that the data type is unsigned, int value in Arduino should be stored from 0 to 65535. But even though I am assigning value less than 65535, the code is outputting wrong value of -25536 :confused:

int i= 40000u;

void setup(){
Serial.begin(9600);
Serial.println(i);
}

void loop(){}

40000 is not representable in a sixteen bit signed int.
Use "unsigned int" or uint16_t

You specifically defined i as a signed int. You can't then override that definition by just adding U after the initialisation value.

Steve