Printing with HEX

Hi everyone,

For a project i need to send 32 bits of data via serial in HEX format, 8 hex bytes. in addition to this i need to have an ascii " : " that supposedly symbolizes HEX. Does Serial.print( num, HEX); take care of this for me already? Do i need to have Serial.print(num, HEX); as well as put "3A" the Hex equivalent of " : " in front of my data? Here is the code I found in reference to printing in HEX format, can someone explain it to me?

#if ARDUINO >= 100
size_t Print::printNumberHex(unsigned long n)
#else
void Print::printNumberHex(unsigned long n)
#endif
{
uint8_t digit, buf[8], *p;

p = buf + (sizeof(buf)-1);
do {
digit = n & 15;
*--p = (digit < 10) ? '0' + digit : 'A' + digit - 10;
n >>= 4;
} while (n);
#if ARDUINO >= 100
return write(p, sizeof(buf)-1 - (p - buf));
#else
write(p, sizeof(buf)-1 - (p - buf));
#endif
}

Thank you for your help,
rekcut

For a project i need to send 32 bits of data via serial in HEX format, 8 hex bytes. in addition to this i need to have an ascii " : " that supposedly symbolizes HEX. Does Serial.print( num, HEX); take care of this for me already? Do i need to have Serial.print(num, HEX); as well as put "3A" the Hex equivalent of " : " in front of my data?

I have had a brilliant idea. Why don't you try printing to the serial monitor and see for yourself ?