Hi All,
I need some help converting a long 2711790500 (0xA1A2A3A4) to 2762187425 (0xA4A3A3A1)
Here is the code I am trying...
void setup()
{
Serial.begin(9600);
unsigned long n = 2711790500;
byte buf[4];
buf[0] = byte(n);
buf[1] = byte(n >> 8);
buf[2] = byte(n >> 16);
buf[3] = byte(n >> 24);
unsigned long value = (unsigned long) (buf[0] << 24) | (unsigned long) (buf[1] << 16) | (unsigned long) (buf[2] << 8) | (unsigned long) buf[3];
Serial.println(value, HEX);
}
void loop() {
// put your main code here, to run repeatedly:
}
This seems to give me an output of 0xFFFFA2A1.
I'm struggling to see what I'm doing wrong can anybody help?
Thanks