data type int: 2 bytes or 4 ?


hi,

does 'int' data type consist of 2 bytes or 4?

code:
 int = -1;
 serial.println(a, bin);

 byte = highbyte(a);
 byte b = lowbyte(a);
 serial.println(a, bin);
 serial.println(b, bin);
 
 int b = word(a, b);
 serial.println(b, bin);
 serial.println(b, dec);

-------------------------
output:

a = -1
11111111111111111111111111111111
11111111
11111111
11111111111111111111111111111111
-1

a = 31000
111100100011000
1111001
11000
111100100011000
31000

a = -31000
11111111111111111000011011101000
10000110
11101000
11111111111111111000011011101000
-31000


the reference section gives int 2 bytes.

also, how can function word() reassemble 4 bytes? takes 2 times 1 byte arguments. right?

again, number of bytes 2 positive numbers , 4 negative ones. correct?

thanks clarification,

newbee

on arduino, 2.
how can have different numbers of bytes positive , negative numbers?

google 'twos complement'


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > data type int: 2 bytes or 4 ?


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums