Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Conversions/DecimalToHex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function intToHex(num){
switch(num){
case 10: return "A";
case 11: return "B";
case 12: return "C";
case 13: return "D";
case 14: return "E";
case 15: return "F";
}
return num;
}
function decimalToHex(num){
let hex_out = [];
while(num > 15) {
hex_out.push(intToHex(num%16));
num = Math.floor(num / 16);
}
return hex_out.join("");
}