int16_t strange behaviour?
Posted: Thu May 14, 2020 7:28 am
This might be a really stupid question, but I'm a little bit confused.
I use an int16_t variable in a bluepill Programm and would like to do some bit operations - but it does not work as i expect it.
when I use Serial.print() i would expect something with 4 Hex Variables, but it returns 8:
Serial Print:
Is there some internal Serial.print() cast?
I use an int16_t variable in a bluepill Programm and would like to do some bit operations - but it does not work as i expect it.
when I use Serial.print() i would expect something with 4 Hex Variables, but it returns 8:
Code: Select all
int16_t c = 0x8000;
int16_t d = 0x4000;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// Wait for USB Serial
while (!Serial) {
}
delay(1000);
Serial.println(c,HEX);
}
void loop() {
// put your main code here, to run repeatedly:
}
Code: Select all
FFFF8000