Serial.println with unsigne long
hi all!
i rading 3 bytes eeprom. time vale (in seconds). want print out.
my code follow:
the 3 bytes declared bytes, result declared (unsigne long).
for 3 bytes:0 7f f9 32761, ok.
but for: 0 80 17 getting 4294934551.
has idea, what's wrong? expecting 32762 .
regards
hans
i rading 3 bytes eeprom. time vale (in seconds). want print out.
my code follow:
code: [select]
high_byte=eeprom1024.read(adress++);
mid_byte=eeprom1024.read(adress++);
low_byte=eeprom1024.read(adress++);
result=(high_byte << 16) | (mid_byte << 8) | low_byte;
serial.print((unsigned long)result);the 3 bytes declared bytes, result declared (unsigne long).
for 3 bytes:0 7f f9 32761, ok.

but for: 0 80 17 getting 4294934551.

has idea, what's wrong? expecting 32762 .
regards
hans
the significan byte of 80 expanded left sign bit.
4294934551 = ffff8017 = 1111 1111 1111 1111 1000 0000 0001 0111
can post declarations used vars involved ?
4294934551 = ffff8017 = 1111 1111 1111 1111 1000 0000 0001 0111
can post declarations used vars involved ?
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Serial.println with unsigne long
arduino
Comments
Post a Comment