Hello,
the Arduino IDE makes me realy confused:
example:
unsigned int ui = 32768;
Serial.println(ui, BIN);
int si = -32768;
Serial.println(si, BIN);
Serial.println(si, DEC);
a unsigned Integer ui = 32768 has a binary representation : 1000000000000000
all fine, it is a 2 Byte Integer
now a signed Integer si = -32768, and now a confusion, this has a binary representation : 11111111111111111000000000000000
in the end, the Serial.println(si,BIN) shows a 4 byte Integer ... so whats going on here ???
so now some thougts about the valid datatypes in the Arduino IDE:
many from c adapted code in the internet use a short datatyp in a Arduino Sketch. But the Ardiono Doc knows no short... so why can i compile code with a not valid datatype?
short s = 16384;
Serial.println(s, BIN);
Serial.println(s, DEC);
100000000000000 = 15 bits, the 15. bit is also only 16384 ? ...
16384
now short s = -16384;
short s = -16384;
Serial.println(s, BIN);
Serial.println(s, DEC);
11111111111111111100000000000000 : Wow, now we have a 4 byte "short"... whats going on here? is the serial.println implementation not correct?
my environment: win 7 64bit or Mac OSX Snow Leopard, Arduino IDE 22
Cheers
sbod