Skip to content

Commit 31d5467

Browse files
committed
added DecimalToHex
1 parent 2d50357 commit 31d5467

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Conversions/DecimalToHex.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function intToHex(num){
2+
switch(num){
3+
case 10: return "A";
4+
case 11: return "B";
5+
case 12: return "C";
6+
case 13: return "D";
7+
case 14: return "E";
8+
case 15: return "F";
9+
}
10+
return num;
11+
}
12+
function decimalToHex(num){
13+
let hex_out = [];
14+
while(num > 15) {
15+
hex_out.push(intToHex(num%16));
16+
num = Math.floor(num / 16);
17+
}
18+
return hex_out.join("");
19+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy