Created
August 7, 2019 16:21
-
-
Save parzibyte/c755146561153ce158ad0faa0cb9fec5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Desde otras bases a decimal | |
* parzibyte.me/blog | |
* @author parzibyte | |
*/ | |
// Binario a decimal | |
let binario = "1100"; // 12 | |
let binarioEnDecimal = parseInt(binario, 2); // La base es 2 | |
console.log("El número binario %s en decimal es %s", binario, binarioEnDecimal); | |
// Octal a decimal | |
let octal = "60"; // 48 | |
let octalEnDecimal = parseInt(octal, 8); // La base es 8 | |
console.log("El número octal %s en decimal es %s", octal, octalEnDecimal); | |
// Hexadecimal a decimal | |
let hexadecimal = "FF"; // 255 | |
let hexadecimalEnDecimal = parseInt(hexadecimal, 16); // La base es 16 | |
console.log("El número hexadecimal %s en decimal es %s", hexadecimal, hexadecimalEnDecimal); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment