
Number Base Conversions: Why Every Developer Hits a Wall Without Them
The first time I encountered hexadecimal color codes in CSS, I did not think about number bases at all. #FF5733 was just a magic string that made things orange. It was not until I tried to programmatically darken a color by 20% that I realized I needed to actually understand what those letters and numbers meant -- and that meant understanding how to convert between binary, decimal, and hexadecimal. Number base conversion is one of those skills that feels academic until suddenly it is not. The Base System Every number system works the same way. In decimal (base 10), the number 347 means: 3 x 10^2 + 4 x 10^1 + 7 x 10^0 = 300 + 40 + 7 = 347 In binary (base 2), the number 1011 means: 1 x 2^3 + 0 x 2^2 + 1 x 2^1 + 1 x 2^0 = 8 + 0 + 2 + 1 = 11 (in decimal) In hexadecimal (base 16), the number 2F means: 2 x 16^1 + F(15) x 16^0 = 32 + 15 = 47 (in decimal) In octal (base 8), the number 73 means: 7 x 8^1 + 3 x 8^0 = 56 + 3 = 59 (in decimal) Once you see the pattern, every base conversion is just
Continue reading on Dev.to Webdev
Opens in a new tab




