Created
February 15, 2014 17:59
-
-
Save alvareztech/9022836 to your computer and use it in GitHub Desktop.
Java: Convertir de una base numerica a otra.
This file contains hidden or 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 String convertir(String numero, int baseOrigen, int baseDestino) { | |
int numeroBase10 = Integer.parseInt(numero, baseOrigen); // convierte a base 10 cualquier numero en otra base | |
String numeroBaseB = Integer.toString(numeroBase10, baseDestino); // convierte numeroBase10 a otra base | |
return numeroBaseB; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment