Skip to content

Instantly share code, notes, and snippets.

@marwein
Last active August 29, 2015 13:58
Show Gist options
  • Select an option

  • Save marwein/9955562 to your computer and use it in GitHub Desktop.

Select an option

Save marwein/9955562 to your computer and use it in GitHub Desktop.
Conv Bin To Dec
Program conv;
Uses crt;
Var
nbr : string;
Function Puissance(nombre,puiss : integer) : Qword;
Begin
if (puiss > 0) Then
Puissance := nombre * Puissance(nombre, puiss - 1)
else
Puissance := 1;
End;
Function Conv2a10(nombre : string) : Qword;
Var
i, longueur : integer;
decimal : Qword;
Begin
i := 0;
decimal := 0;
longueur := length(nombre);
While i <= longueur Do
Begin
if nombre[i] = '1' Then
decimal := decimal + Puissance(2, longueur - i);
Inc(i);
end;
Conv2a10 := decimal;
end;
begin
writeln('Saisissez le Code Binaire a convertir SVP : ');
readln(nbr);
write('(',nbr,')2 => (',Conv2a10(nbr),')10');
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment