Convert Decimal to Hex


/ Published in: JavaScript
Save to your folder(s)

Taken online


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.