title: C: Correct way to print "unsigned long" in hex
body: <p>I have a function that gets an <strong>unsigned long</strong> variable as parameter and I want to print it in Hex.</p>
  <p>What is the correct way to do it?</p>
  <p>Currently, I use <strong>printf</strong> with <strong>&quot;%lx&quot;</strong></p>
  <pre><code>void printAddress(unsigned long address) {
      printf(&quot;%lx\n&quot;, address);
  }
  </code></pre>
  <p>Should I look for a printf pattern for <strong>unsigned</strong> long hex? (and not just &quot;long hex&quot; as mentioned above)</p>
  <p>Or does <strong>printf</strong> convert numbers to hex only using the bits? - so I should not care about the sign anyway?</p>
  <h2>Edit/Clarification</h2>
  <p>This question was rooted in a <strong>confusion</strong>: hex is just another way to express <strong>bits</strong>, which means that signed/unsigned number is just an interpretation. The fact that the type is <strong>unsigned</strong> long therefore doesn't change the hex digits. Unsigned just tells you how to interpret those same bits in your computer program.</p>