title: C# to C++ function equivelent - .tostring("X4")
body: <p>Is there a functional equivalent for the C# function .tostring(&quot;X4&quot;), to C++?</p>
  <p>I've been scratching my head for a few days wondering why my sensor is reporting a different serial number to what the manufacturer software (written in C#) and what my C++ code reports. The serial number is also written on the sensor, which ties in with what the manufacturer C# code reports. On inspection of their source code, they're using the .tostring(&quot;X4&quot;) function to convert it to &quot;human readable&quot;, which makes sense (from a &quot;oh thats why it's different&quot;, not a &quot;why on earth would you do that&quot; point of view).</p>
  <p>For further info - <a href="https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings</a></p>
  <p>A similar question but C# to Java - <a href="https://stackoverflow.com/questions/23107029/c-sharp-tostringx4-equivalent-in-java">C# .ToString(&quot;X4&quot;) equivalent in Java</a></p>