Skip to content

Instantly share code, notes, and snippets.

@alvareztech
Created February 15, 2014 17:59
Show Gist options
  • Save alvareztech/9022836 to your computer and use it in GitHub Desktop.
Save alvareztech/9022836 to your computer and use it in GitHub Desktop.
Java: Convertir de una base numerica a otra.
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