Code to reverse a HEX value and convert to Decimal

PeterH:
Is it only the 4-byte scenario that you need to deal with? The sketch you posted that some UIDs might be 7-byte values. Processing those as you describe would be a very different proposition.

For the 4-byte scenario, I think you just need to convert the 4 byte values into a 32-bit long by shifting and adding the bytes in the right order. A 'for' loop would be the natural way to do that.

    long result = 0;

for (int i=3; i >= 0; i--)
    {
        result = (result << 8) + uid[i];
    }




Then you can just print the value. You want it printed as a decimal number, and the print() method will do that by default if you don't specify the radix.

Yep, it is.

Thanks mate, I already figured a solution that works for me 3 posts up.

I should have taken that section of code out, but it was the UID example from the PN532 library, so I just pasted it in it's entirety.

All of the cards I will be encountering will be the Mifare 1K S50 (Classic), so will only have 4 byte UID's.

I'm sure perhaps the same method could be used for the Mifare Plus cards, but it's not applicable to my situation.

Thanks all the same...