I want to print out some hex values longer than 4 hex values long. I'm following a thread from a decade ago and it works perfectly up until 4 values. And recommendations on how to fix this in my code? I know that the value is actually being written into memory properly. I just can't write to Serial correctly. Currently it's chopping off any value above bit 4.
Ex).
0x00FFFF
0x00000 <- Should be 0x010000
0x00001 <- Should be 0x010001
Yep that works up through 8 bytes on Uno. AWOL's code works on my ESP32 but not the Uno. Probably something related to support for larger structures. Regardless thanks to you both!
Long story short. The "X" parameter is just another reference to unsigned int. Changing the number of bytes requested doesn't change the bits written. "l" is for long. So effectively I needed to print a long int instead of just int.
I think I'd like to see leading zeroes in the format specifier, at least for the least significant part (see reply #8) - your example may work with the data given, but could give misleading results for other values.
You are right. I forgot the leading zeros, and I missed that your answer worked for 64 bit numbers as well as 32 bit numbers.
One reason I like sprintf is that it computes the leading zeros for you. When I see folks zero-pad the numbers by writing code to conditionally Serial.print('0') in something like "01:02:03.000004", why not sprintf(buff,"%02d:%02d:%02d.%06d",hour,min,sec,us);