Languages
[Edit]
EN

TypeScript - convert decimal number to bin, oct, hex, etc. (to any base system)

0 points
Created by:
Lillie-Rose-Finnegan
489

In this short article, we would like to show how to convert any decimal number to the indicated base system using TypeScript.

Quick solution:

 

Custom implementation

Edit

The below function is able to convert from decimal to:

  • bin (binary system),
  • oct (octal systems),
  • hex (hexal / hexadecimal system),
  • any indicated but not greater than 36 (add more characters to the alphabet to get greater base systems).

Practical example:

Output:

Alternative titles

  1. TypeScript - convert dec number to bin, oct, hex, etc. (to any base system)
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join