Created
February 11, 2020 16:34
-
-
Save parzibyte/fae9f3bb7caf7ca743424dcfd2b6e128 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
public static long octalADecimal(String octal) { | |
long decimal = 0; | |
int potencia = 0; | |
for (int x = octal.length() - 1; x >= 0; x--) { | |
int valorActual = Character.getNumericValue(octal.charAt(x)); | |
long elevado = (long) Math.pow(8, potencia) * valorActual; | |
decimal += elevado; | |
potencia++; | |
} | |
return decimal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment