This week I’ll be publishing a JavaScript module that converts any decimal integer to another base; eg. hex, octal, or binary. By default it will allow for bases as large as 36, and if possible I’ll also enable options for increasing the base size as well as modifying symbols used for conversion.

Example of expected usage…

decimalToBase(10, 16);
//> "0xA"

decimalToBase(10, 8);
//> "0o12"

decimalToBase(10, 2);
//> "0b1010"

Update

As of Jun 23, 2020 this project is now live!

Clone via…

git clone git@github.com:javascript-utilities/decimal-to-base.git

Documentation is currently within the ReadMe file, source code may be perused on GitHub, and a live demo is available for testing thanks to GitHub Pages.