Commentaire de code

bifaka -  
 Utilisateur anonyme -
merci de vouloir bien m'aider. Peux tu commenter ton algorithme?
Si ca ne te gene pas, j'aimerai avoir ton adresse internet pour directement de poser la question si j'en ai une. Je te trouve génial.
voici la mienne: domancini@yahoo.fr
Bonne journée à toi.


public class Converter {

public static long hexToDec(String hex) {
long n = 0;
for (int i = 0; i < hex.length(); i++) {
char charHex = hex.charAt(i);
int exponent = hex.length() - (i + 1);
long mult = (long)Math.pow(16, exponent);
if (charHex >= 65) {
n += (charHex - 55) * mult;
} else {
n += (charHex-48) * mult;
}
}
return n;
}

public static void main(String[] args) {
System.out.println(Converter.hexToDec("AAA"));
}
}
A voir également:

3 réponses

sebsauvage Messages postés 32893 Date d'inscription   Statut Modérateur Dernière intervention   15 662
 
C'est à rendre pour quand ?
1
bifaka
 
merci sebsauvage c'est à rendre Lundi le 19.12.05.
1
Utilisateur anonyme
 
LOL !
0
Utilisateur anonyme
 
Bon. On aide les gens, on leur rend service. Te donner la solution tout cru ne te rendrait pas service et ne t'avancerait à rien.

Ce n'est quand meme pas bien difficile de commenter ligne à ligne ce tout petit bout de programme.
1