Posted By

resting on 10/17/10


Tagged

hex decimal


Versions (?)

Convert Decimal to Hex


 / Published in: JavaScript
 

Taken online

  1. function decimalToHex(d, padding) {
  2. var hex = Number(d).toString(16);
  3. padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding;
  4.  
  5. while (hex.length < padding) {
  6. hex = "0" + hex;
  7. }
  8.  
  9. return hex;
  10. }

Report this snippet  

You need to login to post a comment.