Tout sur la programmation
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Tout sur la programmation

programmation de tous les languages
 
AccueilPortailRechercherDernières imagesS'enregistrerConnexion
Le Deal du moment :
Cartes Pokémon 151 : où trouver le ...
Voir le deal

 

 convertisseur binaire, décimal et hexadécimal

Aller en bas 
3 participants
AuteurMessage
Black Templar
Admin
Admin
Black Templar


Nombre de messages : 356
Age : 35
Localisation : Lille (France)
language de prog : Liberty BASIC; HTML; CSS; php; MySQL; C
expérience en prog : Amateur
Date d'inscription : 06/08/2005

convertisseur binaire, décimal et hexadécimal Empty
MessageSujet: convertisseur binaire, décimal et hexadécimal   convertisseur binaire, décimal et hexadécimal EmptyJeu 11 Aoû - 17:02

Bonjour.
Voici un petit programme en liberty basic dont je suis assez fier même si on ne peut pas dépasser 16 bits de nombres. Smile

Qu'en pensez vous?

Code:
'***************************************************
'* CONVERTISSEUR HEXA DEC BIN v:1.1                *
'*                                                *
'* Created by Black Templar Août 2005              *
'*                                                *
'* programme permettant de convertir des nombres  *
'* décimal en hexadécimal et binaire              *
'*                                                *
'* OPEN SOURCE                                    *
'***************************************************
NOMAINWIN
DIM L1(16)
DIM L2(4)
DIM L2$(4)
DIM L3(16)
DIM X(4)
BackgroundColor$ = "Darkcyan"
ForegroundColor$ = "White"
TextboxColor$ = "Black"
STATICTEXT #1 , "Tapez votre nombre en :" , 50 , 15 , 200 , 20
RADIOBUTTON #1.r1 , "Décimal  (<65536)" , [butD] , [wait] , 50 , 60 , 300 , 20
RADIOBUTTON #1.r2 , "Hexadécimal  (<FFFF)" , [butH] , [wait] , 50 , 110 , 300 , 20
RADIOBUTTON #1.r3 , "Binaire  (<10^16)" , [butB] , [wait] , 50 , 160 , 300 , 20
TEXTBOX #1.txt , 50 , 210 , 150 , 20
BUTTON #1.bouton , "Calculer" , [calculer] , UL , 220 , 205 , 50 , 30
MENU #1 , "&Fichier" , "&Quitter" , [quitter]
UpperLeftX = 400
UpperLeftY = 200
WindowWidth = 320
WindowHeight = 330
OPEN "Convertisseur Binaire, Hexadécimal, Décimal" FOR Window AS #1
PRINT #1 , "trapclose [quitter]"
WAIT
'********** Quitter le programme principale **********
[quitter]
CONFIRM "Voulez-vous vraiment quitter?" ; Quit$
IF Quit$ = "no" THEN WAIT
IF quitter = 1 THEN CLOSE #2
CLOSE #1
END
[butD]
But$ = "Déc"
WAIT
[butH]
But$ = "Hex"
WAIT
[butB]
But$ = "Bin"
WAIT
'********** Renvoi au language sélectionné **********
[calculer]
IF But$ = "" THEN
NOTICE "Selectionnez votre language!"
WAIT
END IF
IF But$ = "Déc" THEN GOTO [Déc]
IF But$ = "Hex" THEN GOTO [Hex]
IF But$ = "Bin" THEN GOTO [Bin]
WAIT
[Déc]
PRINT #1.txt , "!contents?"
INPUT #1.txt , D
IF D > 65535 THEN
NOTICE "Le nombre doit être inférieur à 65536 !"
WAIT
END IF
GOSUB [binaire]
GOSUB [hexadécimal]
GOTO [afficher]
[Bin]
PRINT #1.txt , "!contents?"
INPUT #1.txt , B
IF B > 10^16 THEN
NOTICE "Le nombre doit être inférieur à 10^16 !"
WAIT
END IF
Bi$ = STR$(B)
GOSUB [decbin]
GOSUB [hexadécimal]
GOTO [afficher]
[Hex]
PRINT #1.txt , "!contents?"
INPUT #1.txt , hexa$
hexa$ = TRIM$(hexa$)
XI = LEN(hexa$)
IF XI > 4 THEN
NOTICE "Le nombre doit être inférieur à FFFF !"
WAIT
END IF
'********** Décortique le nombre hexadécimal et calcul le nombre décimal **********
FOR Z = 1 to XI
X$(Z) = MID$(hexa$,Z,1)
IF X$(Z) = "0" THEN X(Z) = 0
IF X$(Z) = "1" THEN X(Z) = 1
IF X$(Z) = "2" THEN X(Z) = 2
IF X$(Z) = "3" THEN X(Z) = 3
IF X$(Z) = "4" THEN X(Z) = 4
IF X$(Z) = "5" THEN X(Z) = 5
IF X$(Z) = "6" THEN X(Z) = 6
IF X$(Z) = "7" THEN X(Z) = 7
IF X$(Z) = "8" THEN X(Z) = 8
IF X$(Z) = "9" THEN X(Z) = 9
IF X$(Z) = "A" OR X$(Z) = "a" THEN X(Z) = 10
IF X$(Z) = "B" OR X$(Z) = "b" THEN X(Z) = 11
IF X$(Z) = "C" OR X$(Z) = "c" THEN X(Z) = 12
IF X$(Z) = "D" OR X$(Z) = "d" THEN X(Z) = 13
IF X$(Z) = "E" OR X$(Z) = "e" THEN X(Z) = 14
IF X$(Z) = "F" OR X$(Z) = "f" THEN X(Z) = 15
NEXT
IF XI = 3 THEN
X(4) = X(3)
X(3) = X(2)
X(2) = X(1)
X(1) = 0
END IF
IF XI = 2 THEN
X(4) = X(2)
X(3) = X(1)
X(2) = 0
X(1) = 0
END IF
IF XI = 1 THEN
X(4) = X(1)
X(3) = 0
X(2) = 0
X(1) = 0
END IF
D = X(4) + 16 * X(3) + 256 * X(2) + 4096 * X(1)
GOSUB [binaire]
GOSUB [hexadécimal]
GOTO [afficher]
'********** Transforme un nombre décimal en binaire **********
[binaire]
L1(1) = 2*(D/2-INT(D/2))
A = INT(D/2)
FOR Z = 2 TO 16
L1(Z) = 2*(A/2-INT(A/2))
A = INT(A/2)
NEXT
Bi$ = ""
FOR Z = 16 TO 1 step -1
Bi$ = Bi$ + STR$(L1(Z))
NEXT
RETURN
'********** Transforme un nombre décimal en hexadécimal **********
[hexadécimal]
L2(1) = 16 * (D / 16 - INT( D / 16))
A = INT(D / 16)
FOR Z = 2 TO 4
L2(Z) = 16 * (A / 16 - INT(A / 16))
A = INT(A / 16)
NEXT
FOR Z = 1 TO 4
IF L2(Z) < 10 THEN L2$(Z) = STR$(L2(Z))
IF L2(Z) = 10 THEN L2$(Z) = "A"
IF L2(Z) = 11 THEN L2$(Z) = "B"
IF L2(Z) = 12 THEN L2$(Z) = "C"
IF L2(Z) = 13 THEN L2$(Z) = "D"
IF L2(Z) = 14 THEN L2$(Z) = "E"
IF L2(Z) = 15 THEN L2$(Z) = "F"
NEXT
H$ = L2$(4) + L2$(3) + L2$(2) + L2$(1)
RETURN
'********** Transforme un nombre binaire en décimal **********
[decbin]
C = INT(B / 10)
L3(1) = B - 10 * C
FOR Z = 2 TO 14 STEP 2
A = INT(C / 10)
L3(Z) = C - 10 * A
C = INT(A / 10)
L3(Z + 1) = A - 10 * C
NEXT
A = INT(C / 10)
L3(16) = C - 10 * A
D = 0
C = 1
FOR Z = 1 TO 16
D = L3(Z) * C + D
C = 2 * C
NEXT
RETURN
'********** Affiche le résultat **********
[afficher]
PRINT #1.txt , ""
UpperLeftX = 400
UpperLeftY = 200
WindowWidth = 100
WindowHeight = 190
STATICTEXT #2 , "Décimal :" , 10 , 10 , 100 , 20
STATICTEXT #2 , "Hexadécimal :" , 10 , 60 , 100 , 20
STATICTEXT #2 , "Binaire :" , 10 , 110 , 100 , 20
STATICTEXT #2 , STR$(D) , 10 , 35 , 100 , 20
STATICTEXT #2 , H$ , 10 , 85 , 100 , 20
STATICTEXT #2 , Bi$ , 10 , 135 , 100 , 20
OPEN "" FOR Window AS #2
quitter = 1
PRINT #2 , "trapclose [quit2]"
WAIT
'********** Ferme la fenètre des résultats **********
[quit2]
CLOSE #2
quitter = 0
WAIT
'*******************************************~~ FIN ~~********************************************
Revenir en haut Aller en bas
http://membres.multimania.fr/templar59
Mike
Admin
Admin
Mike


Nombre de messages : 724
Age : 32
Localisation : Canada, Québec Montréal
language de prog : LB, GM, C++, XHTML, CSS, PHP
expérience en prog : 1 ans d'expérience
Date d'inscription : 21/07/2005

convertisseur binaire, décimal et hexadécimal Empty
MessageSujet: Re: convertisseur binaire, décimal et hexadécimal   convertisseur binaire, décimal et hexadécimal EmptyVen 12 Aoû - 11:31

Je l'essaye dès que je reviens chez nous, et je t'en donne des nouvelles.
Revenir en haut Aller en bas
https://info-programmation.forumactif.com/
Black Templar
Admin
Admin
Black Templar


Nombre de messages : 356
Age : 35
Localisation : Lille (France)
language de prog : Liberty BASIC; HTML; CSS; php; MySQL; C
expérience en prog : Amateur
Date d'inscription : 06/08/2005

convertisseur binaire, décimal et hexadécimal Empty
MessageSujet: Re: convertisseur binaire, décimal et hexadécimal   convertisseur binaire, décimal et hexadécimal EmptyMar 23 Aoû - 10:21

Voila, j'ai trouvé une methode plus simple pour convertir le binaire en décimal.
Voila la nouvelle version:
Code:
'***************************************************
'* CONVERTISSEUR HEXA DEC BIN v:1.2                *
'*                                                *
'* Created by Black Templar Août 2005              *
'*                                                *
'* programme permettant de convertir des nombres  *
'* décimal en hexadécimal et binaire              *
'*                                                *
'* OPEN SOURCE                                    *
'***************************************************
NOMAINWIN
DIM L1(16)
DIM L2(4)
DIM L2$(4)
DIM L3(16)
DIM X(4)
BackgroundColor$ = "Darkcyan"
ForegroundColor$ = "White"
TextboxColor$ = "Black"
STATICTEXT #1 , "Tapez votre nombre en :" , 50 , 15 , 200 , 20
STATICTEXT #1 , "Décimal (<65536)" , 70 , 62 , 200 , 20
STATICTEXT #1 , "Hexadécimal  (<FFFF)" , 70 , 112 , 200 , 20
STATICTEXT #1 , "Binaire  (<10^16)" , 70 , 162 , 200 , 20
RADIOBUTTON #1.r1 , "" , [butD] , [wait] , 50 , 60 , 20 , 20
RADIOBUTTON #1.r2 , "" , [butH] , [wait] , 50 , 110 , 20 , 20
RADIOBUTTON #1.r3 , "" , [butB] , [wait] , 50 , 160 , 20 , 20
TEXTBOX #1.txt , 50 , 210 , 150 , 20
BUTTON #1.bouton , "Calculer" , [calculer] , UL , 220 , 205 , 50 , 30
MENU #1 , "&Fichier" , "&Quitter" , [quitter]
UpperLeftX = 400
UpperLeftY = 200
WindowWidth = 320
WindowHeight = 330
OPEN "Convertisseur Binaire, Hexadécimal, Décimal" FOR Window AS #1
PRINT #1 , "trapclose [quitter]"
WAIT
'********** Quitter le programme principale **********
[quitter]
CONFIRM "Voulez-vous vraiment quitter?" ; Quit$
IF Quit$ = "no" THEN WAIT
IF quitter = 1 THEN CLOSE #2
CLOSE #1
END
[butD]
But$ = "Déc"
WAIT
[butH]
But$ = "Hex"
WAIT
[butB]
But$ = "Bin"
WAIT
'********** Renvoi au language sélectionné **********
[calculer]
IF But$ = "" THEN
NOTICE "Selectionnez votre language!"
WAIT
END IF
IF But$ = "Déc" THEN GOTO [Déc]
IF But$ = "Hex" THEN GOTO [Hex]
IF But$ = "Bin" THEN GOTO [Bin]
WAIT
[Déc]
PRINT #1.txt , "!contents?"
INPUT #1.txt , D
IF D > 65535 THEN
NOTICE "Le nombre doit être inférieur à 65536 !"
WAIT
END IF
GOSUB [binaire]
GOSUB [hexadécimal]
GOTO [afficher]
[Bin]
PRINT #1.txt , "!contents?"
INPUT #1.txt , B
IF B > 10^16 THEN
NOTICE "Le nombre doit être inférieur à 10^16 !"
WAIT
END IF
Bi$ = STR$(B)
GOSUB [decbin]
GOSUB [hexadécimal]
GOTO [afficher]
[Hex]
PRINT #1.txt , "!contents?"
INPUT #1.txt , hexa$
hexa$ = TRIM$(hexa$)
XI = LEN(hexa$)
IF XI > 4 THEN
NOTICE "Le nombre doit être inférieur à FFFF !"
WAIT
END IF
'********** Décortique le nombre hexadécimal et calcul le nombre décimal **********
FOR Z = 1 to XI
X$(Z) = MID$(hexa$,Z,1)
IF X$(Z) = "0" THEN X(Z) = 0
IF X$(Z) = "1" THEN X(Z) = 1
IF X$(Z) = "2" THEN X(Z) = 2
IF X$(Z) = "3" THEN X(Z) = 3
IF X$(Z) = "4" THEN X(Z) = 4
IF X$(Z) = "5" THEN X(Z) = 5
IF X$(Z) = "6" THEN X(Z) = 6
IF X$(Z) = "7" THEN X(Z) = 7
IF X$(Z) = "8" THEN X(Z) = 8
IF X$(Z) = "9" THEN X(Z) = 9
IF X$(Z) = "A" OR X$(Z) = "a" THEN X(Z) = 10
IF X$(Z) = "B" OR X$(Z) = "b" THEN X(Z) = 11
IF X$(Z) = "C" OR X$(Z) = "c" THEN X(Z) = 12
IF X$(Z) = "D" OR X$(Z) = "d" THEN X(Z) = 13
IF X$(Z) = "E" OR X$(Z) = "e" THEN X(Z) = 14
IF X$(Z) = "F" OR X$(Z) = "f" THEN X(Z) = 15
NEXT
IF XI = 3 THEN
X(4) = X(3)
X(3) = X(2)
X(2) = X(1)
X(1) = 0
END IF
IF XI = 2 THEN
X(4) = X(2)
X(3) = X(1)
X(2) = 0
X(1) = 0
END IF
IF XI = 1 THEN
X(4) = X(1)
X(3) = 0
X(2) = 0
X(1) = 0
END IF
D = X(4) + 16 * X(3) + 256 * X(2) + 4096 * X(1)
GOSUB [binaire]
GOSUB [hexadécimal]
GOTO [afficher]
'********** Transforme un nombre décimal en binaire **********
[binaire]
L1(1) = 2*(D/2-INT(D/2))
A = INT(D/2)
FOR Z = 2 TO 16
L1(Z) = 2*(A/2-INT(A/2))
A = INT(A/2)
NEXT
Bi$ = ""
FOR Z = 16 TO 1 step -1
Bi$ = Bi$ + STR$(L1(Z))
NEXT
RETURN
'********** Transforme un nombre décimal en hexadécimal **********
[hexadécimal]
L2(1) = 16 * (D / 16 - INT( D / 16))
A = INT(D / 16)
FOR Z = 2 TO 4
L2(Z) = 16 * (A / 16 - INT(A / 16))
A = INT(A / 16)
NEXT
FOR Z = 1 TO 4
IF L2(Z) < 10 THEN L2$(Z) = STR$(L2(Z))
IF L2(Z) = 10 THEN L2$(Z) = "A"
IF L2(Z) = 11 THEN L2$(Z) = "B"
IF L2(Z) = 12 THEN L2$(Z) = "C"
IF L2(Z) = 13 THEN L2$(Z) = "D"
IF L2(Z) = 14 THEN L2$(Z) = "E"
IF L2(Z) = 15 THEN L2$(Z) = "F"
NEXT
H$ = L2$(4) + L2$(3) + L2$(2) + L2$(1)
RETURN
'********** Transforme un nombre binaire en décimal **********
[decbin]
a = 1
D = 0
FOR z = len(str$(B)) TO 1 step -1
b$ = mid$(str$(B), z, 1)
b= val(b$)
D = a * b + D
a = a * 2
NEXT
RETURN
'********** Affiche le résultat **********
[afficher]
PRINT #1.txt , ""
UpperLeftX = 400
UpperLeftY = 200
WindowWidth = 100
WindowHeight = 190
STATICTEXT #2 , "Décimal :" , 10 , 10 , 100 , 20
STATICTEXT #2 , "Hexadécimal :" , 10 , 60 , 100 , 20
STATICTEXT #2 , "Binaire :" , 10 , 110 , 100 , 20
STATICTEXT #2 , STR$(D) , 10 , 35 , 100 , 20
STATICTEXT #2 , H$ , 10 , 85 , 100 , 20
STATICTEXT #2 , Bi$ , 10 , 135 , 100 , 20
OPEN "" FOR Window AS #2
quitter = 1
PRINT #2 , "trapclose [quit2]"
WAIT
'********** Ferme la fenètre des résultats **********
[quit2]
CLOSE #2
quitter = 0
WAIT
'*******************************************~~ FIN ~~********************************************


Revenir en haut Aller en bas
http://membres.multimania.fr/templar59
Mike
Admin
Admin
Mike


Nombre de messages : 724
Age : 32
Localisation : Canada, Québec Montréal
language de prog : LB, GM, C++, XHTML, CSS, PHP
expérience en prog : 1 ans d'expérience
Date d'inscription : 21/07/2005

convertisseur binaire, décimal et hexadécimal Empty
MessageSujet: Re: convertisseur binaire, décimal et hexadécimal   convertisseur binaire, décimal et hexadécimal EmptyMar 23 Aoû - 10:26

Il est très bien ce prog.
Très utiles. Mais il faudrait que tu trouve un moyen de pouvoir prendre n'importe quel nombre
Revenir en haut Aller en bas
https://info-programmation.forumactif.com/
Black Templar
Admin
Admin
Black Templar


Nombre de messages : 356
Age : 35
Localisation : Lille (France)
language de prog : Liberty BASIC; HTML; CSS; php; MySQL; C
expérience en prog : Amateur
Date d'inscription : 06/08/2005

convertisseur binaire, décimal et hexadécimal Empty
MessageSujet: Re: convertisseur binaire, décimal et hexadécimal   convertisseur binaire, décimal et hexadécimal EmptyMar 23 Aoû - 10:29

ouai, j'vais y réfléchir.
Revenir en haut Aller en bas
http://membres.multimania.fr/templar59
Black Templar
Admin
Admin
Black Templar


Nombre de messages : 356
Age : 35
Localisation : Lille (France)
language de prog : Liberty BASIC; HTML; CSS; php; MySQL; C
expérience en prog : Amateur
Date d'inscription : 06/08/2005

convertisseur binaire, décimal et hexadécimal Empty
MessageSujet: Re: convertisseur binaire, décimal et hexadécimal   convertisseur binaire, décimal et hexadécimal EmptyMer 24 Aoû - 11:25

Voila, j'ai changé des parties de mon code avec l'aide de Pascal de http://lbasic.atomysk.com/forum/ et je l'ai indenté

Code:
'***************************************************
'* CONVERTISSEUR HEXA DEC BIN v:1.3                *
'*                                                *
'* Created by Black Templar Août 2005              *
'*                                                *
'* programme permettant de convertir des nombres  *
'* décimal en hexadécimal et binaire              *
'*                                                *
'* OPEN SOURCE                                    *
'***************************************************

    nomainwin
    dim L1(16), L2(4), L3(16), X(4), X2(4)
    dim L2$(4)
    BackgroundColor$ = "Darkcyan"
    ForegroundColor$ = "White"
    TextboxColor$ = "Black"
    statictext #1 , "Tapez votre nombre en :" , 10 , 10 , 200 , 20
    statictext #1 , "Décimal (<65536)" , 30 , 43 , 200 , 20
    statictext #1 , "Hexadécimal  (<FFFF)" , 30 , 73 , 200 , 20
    statictext #1 , "Binaire  (<10^16)" , 30 , 103 , 200 , 20
    radiobutton #1.r1 , "" , [butD] , [wait] , 10 , 40 , 20 , 20
    radiobutton #1.r2 , "" , [butH] , [wait] , 10 , 70 , 20 , 20
    radiobutton #1.r3 , "" , [butB] , [wait] , 10 , 100 , 20 , 20
    textbox #1.txt , 10 , 130 , 130 , 20
    button #1.bouton , "Calculer" , [calculer] , UL , 10 , 160 , 130 , 20
    menu #1 , "&Fichier" , "&Quitter" , [quitter]
    UpperLeftX = 400
    UpperLeftY = 200
    WindowWidth = 160
    WindowHeight = 245
open "Convertisseur Binaire, Hexadécimal, Décimal" for Window as #1
    print #1 , "trapclose [quitter]"
    wait

'********** Quitter le programme principale **********

    [quitter]
    confirm "Voulez-vous vraiment quitter?" ; Quit$
    if Quit$ = "no" then wait
    if quitter = 1 then close #2
    close #1
    end

    [butD]
    But$ = "Déc"
    wait

    [butH]
    But$ = "Hex"
    wait

    [butB]
    But$ = "Bin"
    wait

'********** Renvoi au language sélectionné **********

    [calculer]
    if But$ = "" then
        notice "Selectionnez votre language!"
        wait
    end if

    if But$ = "Déc" then goto [Déc]
    if But$ = "Hex" then goto [Hex]
    if But$ = "Bin" then goto [Bin]
    wait

    [Déc]
    print #1.txt , "!contents?"
    input #1.txt , D

    if D > 65535 then
        notice "Le nombre doit être inférieur à 65536 !"
        wait
    end if

    gosub [binaire]
    gosub [hexadécimal]
    goto [afficher]

    [Bin]
    print #1.txt , "!contents?"
    input #1.txt , B

    if B > 10^16 then
        notice "Le nombre doit être inférieur à 10^16 !"
        wait
    end if

    Bi$ = STR$(B)
    gosub [decbin]
    gosub [hexadécimal]
    goto [afficher]

    [Hex]
    print #1.txt , "!contents?"
    input #1.txt , hexa$
    hexa$ = TRIM$(hexa$)
    XI = LEN(hexa$)

    if XI > 4 then
        notice "Le nombre doit être inférieur à FFFF !"
        wait
    end if

'********** Décortique le nombre hexadécimal et calcul le nombre décimal **********

    for Z = 1 to XI
        X(Z) = asc(UPPER$(MID$(hexa$,Z,1)))-48
        X(Z) = (X(Z)<10)*X(Z)+(X(Z)>9)*(X(Z)-7)
    next

    for z=1 to 4
        X2(z)=X(z)
        if z<=(4-XI) then  X(z)=0 else X(z)=X2(XI+z-4)
    next

    D = X(4) + 16 * X(3) + 256 * X(2) + 4096 * X(1)
    gosub [binaire]
    gosub [hexadécimal]
    goto [afficher]

'********** Transforme un nombre décimal en binaire **********

    [binaire]
    L1(1) = 2*(D/2-INT(D/2))
    A = INT(D/2)

    for Z = 2 to 16
        L1(Z) = 2*(A/2-INT(A/2))
        A = INT(A/2)
    next

    Bi$ = ""

    for Z = 16 to 1 step -1
        Bi$ = Bi$ + STR$(L1(Z))
    next

    for z = 1 to 16
        if mid$(Bi$,z,1) = "1" then exit for
    next

    Binaire$ = ""
    Binaire$ = Binaire$ + right$(Bi$, 16- z+ 1)
    Bi$ = Binaire$
    return

'********** Transforme un nombre décimal en hexadécimal **********

    [hexadécimal]
    L2(1) = 16 * (D / 16 - INT( D / 16))
    A = INT(D / 16)

    for Z = 2 to 4
        L2(Z) = 16 * (A / 16 - INT(A / 16))
        A = INT(A / 16)
    next

    for Z = 1 to 4
        if L2(Z) < 10 then L2$(Z) = STR$(L2(Z))
        if L2(Z) = 10 then L2$(Z) = "A"
        if L2(Z) = 11 then L2$(Z) = "B"
        if L2(Z) = 12 then L2$(Z) = "C"
        if L2(Z) = 13 then L2$(Z) = "D"
        if L2(Z) = 14 then L2$(Z) = "E"
        if L2(Z) = 15 then L2$(Z) = "F"
    next

    H$ = L2$(4) + L2$(3) + L2$(2) + L2$(1)

    for z = 1 to 4
        if mid$(H$,z,1) <> "0" then exit for
    next

    Hexadécimal$ = ""
    Hexadécimal$ = Hexadécimal$ + right$(H$, 4- z+ 1)
    H$ = Hexadécimal$
    return

'********** Transforme un nombre binaire en décimal **********

    [decbin]
    a = 1
    D = 0
    for z = len(str$(B)) to 1 step -1
        b$ = mid$(str$(B), z, 1)
        b= val(b$)
        D = a * b + D
        a = a * 2
    next
    return

'********** Affiche le résultat **********

    [afficher]
    print #1.txt , ""
    UpperLeftX = 400
    UpperLeftY = 200
    WindowWidth = 100
    WindowHeight = 190
    statictext #2 , "Décimal :" , 10 , 10 , 100 , 20
    statictext #2 , "Hexadécimal :" , 10 , 60 , 100 , 20
    statictext #2 , "Binaire :" , 10 , 110 , 100 , 20
    statictext #2 , STR$(D) , 10 , 35 , 100 , 20
    statictext #2 , H$ , 10 , 85 , 100 , 20
    statictext #2 , Bi$ , 10 , 135 , 100 , 20
open "" for Window as #2
    quitter = 1
    print #2 , "trapclose [quit2]"
    wait

'********** Ferme la fenètre des résultats **********

    [quit2]
    close #2
    quitter = 0
    wait

'*******************************************~~ FIN ~~********************************************



P.S. : Je pense que 16 bits, ça suffit (ça fait 65535d personne ne devrait utiliser au dessus)
Revenir en haut Aller en bas
http://membres.multimania.fr/templar59
Exedor
programmeur intensif
programmeur intensif
Exedor


Nombre de messages : 304
language de prog : Commence juste d'apprendre le C++
expérience en prog : Passé pas Liberty Basic et blitz basic sans m'arréter.
Date d'inscription : 19/08/2005

convertisseur binaire, décimal et hexadécimal Empty
MessageSujet: Re: convertisseur binaire, décimal et hexadécimal   convertisseur binaire, décimal et hexadécimal EmptyMer 24 Aoû - 11:33

J'ai essayé c'est pas mal applaudisemment
Revenir en haut Aller en bas
http://fanasdharrypotter.free.fr
Contenu sponsorisé





convertisseur binaire, décimal et hexadécimal Empty
MessageSujet: Re: convertisseur binaire, décimal et hexadécimal   convertisseur binaire, décimal et hexadécimal Empty

Revenir en haut Aller en bas
 
convertisseur binaire, décimal et hexadécimal
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» Convertisseur de Température, BUG!!!

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Tout sur la programmation :: Programmation :: Programmes-
Sauter vers: