Skip to content

Instantly share code, notes, and snippets.

Created August 7, 2019 16:20
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
* Desde decimal a otras bases
* @author parzibyte
let decimal = 255; // Este número lo iremos convirtiendo a todas las bases
// Decimal a binario
let decimalEnBinario = decimal.toString(2); // A la base 2
console.log("El número decimal %s en binario es %s", decimal, decimalEnBinario);
// Decimal a octal
let decimalEnOctal = decimal.toString(8); // A la base 8
console.log("El número decimal %s en octal es %s", decimal, decimalEnOctal);
// Decimal a hexadecimal
let decimalEnHexadecimal = decimal.toString(16); // A la base 16
console.log("El número decimal %s en hexadecimal es %s", decimal, decimalEnHexadecimal);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment