title: PHP dechex change amount of bytes in output
body: <p>Hi I am working on creating an assembler and so I need to take some number and convert it to hex for a branch command. Is there a way to change the amount of bytes returned in the output? We are using 24 bit instructions (6 bytes) and our branch commands use the first byte for op code and second byte for conditional bits, that leaves me 4 bytes for the number. If I have a negative number like -2 I get <code>fffffffffffffffe</code> which is 16 bytes. Is there an easy way to change the output of <code>hexdec()</code> to a specified number of bytes? I know how to do positive numbers as they output the minimum amount of bytes needed so 2 becomes 2 or 15 becomes f. </p>
  
  <p>If I went from integer to binary using <code>decbin</code> I still get 16 bytes. <strong>I can not just cut off any leading bytes can I?</strong> </p>