Pblm de transfert d'1 nbr de base 36 en base 10

Aurelyyy Messages postés 4 Date d'inscription jeudi 19 décembre 2002 Statut Membre Dernière intervention 19 février 2003 - 23 janv. 2003 à 14:47
Aurelyyy Messages postés 4 Date d'inscription jeudi 19 décembre 2002 Statut Membre Dernière intervention 19 février 2003 - 27 janv. 2003 à 09:02
Salut,
dans ma base SQL j'ai un identifiant salarié qui est en base 36.
ex : 17C, 17 D ect...
et il faut que je le passe en base 10.
Es ce que qq1 aurait la formule en asp? SVP.
MERCI

:shy)

4 réponses

cs_Mcjo Messages postés 403 Date d'inscription dimanche 12 août 2001 Statut Membre Dernière intervention 3 septembre 2012 2
23 janv. 2003 à 18:25
c'est quoi la base 36??
je connais la base 2, 8, 10, 16 mais la je suis sotcher
si j'ai tout compris 0 en base 36 vaut 0 et z vaut 36
donc la c'est pas compliquer tu applique la formule de conversion par puissance

AX3 (base 36) = 10 * 36^2 + 24*36^1 + 3*36^0
AX3 (base 36) = 12960 + 864 + 3
AX3 (base 36) = 13827 (base 10)

ci c'est le cas dit le moi je psu faire un algo
0
Aurelyyy Messages postés 4 Date d'inscription jeudi 19 décembre 2002 Statut Membre Dernière intervention 19 février 2003
24 janv. 2003 à 09:21
T'es super c'est ça la formule. MERCI. Je vais commencer à faire l'algo mais si tu l'as déjà tout près c bien aussi. MERCI.
0
cs_Mcjo Messages postés 403 Date d'inscription dimanche 12 août 2001 Statut Membre Dernière intervention 3 septembre 2012 2
24 janv. 2003 à 15:13
Non mais avec un peu de chance tu doit pouvoir en trouver pour convertir de l'hexa en base 10.
Il te sufirat alors de le modifier un peu

function puissance(a, b)
puissance = 1
if b > 0 then
for = 1 to b
puissance = puissance * a
next
end if
end function

function convertion(a)
if isnumeric(a) then convertion = cint(a)if a "a" then convertion 10if a "b" then convertion 11if a "c" then convertion 12if a "d" then convertion 13if a "e" then convertion 14if a "f" then convertion 15if a "g" then convertion 16if a "h" then convertion 17if a "i" then convertion 18if a "j" then convertion 19if a "k" then convertion 20if a "l" then convertion 21if a "m" then convertion 22if a "n" then convertion 23if a "o" then convertion 24if a "p" then convertion 25if a "q" then convertion 26if a "r" then convertion 27if a "s" then convertion 28if a "t" then convertion 29if a "u" then convertion 30if a "v" then convertion 31if a "w" then convertion 32if a "x" then convertion 33if a "y" then convertion 34if a "z" then convertion 35
end function

function base10(base36)
dim matable
redim matable len(base36)
for i = 1 to len(base36) step 1
matable(i) = mid(base36,i,1)
next

redim matable2(ubound(matable))
j = ubound(matable)
for i = 1 to ubound(matable2)
matable2(i) = matable(j)
j = j - 1
next

for i = 1 to ubound(matable2)
base10 = base10 +puissance(convertion(matable(i)), i - 1)
next

end function

essaie ca mais c tapper a l'arache
0
Aurelyyy Messages postés 4 Date d'inscription jeudi 19 décembre 2002 Statut Membre Dernière intervention 19 février 2003
27 janv. 2003 à 09:02
g trouvé l'algo je l'ai mi ds les math et algorithmes. MERCI.
0
Rejoignez-nous