Konversi Desimal ke Biner

Sekarang kita akan menyajikan suatu fungsi sederhana yaitu mengkonversi dari bilangan desimal ke ke bilangan biner dengan menggunakan Borland Delphi. Silakan lihat fungsi di DecToBinStr berikut ini.

function TForm1.DecToBinStr(bil: integer): string;
var
str : string;
i : integer;
negative: Boolean;
begin
if bil < 0 then
negative := true;
bil:= abs(bil);
for i:= 1 to SizeOf(bil) * 8 do
begin
if bil < 0 then
str := str + ‘1’
else
str := str + ‘0’;
bil := bil shl 1;
end;
delete(str,1,pos(‘1’,str)-1);
if negative then str := ‘-‘ + str;
result := str;
end;

One thought on “Konversi Desimal ke Biner

  1. top gun 12 Mei 2013 pukul 8:22 pm

    Hi mates, how is the whole thing, and what you wish for to say regarding this article, in
    my view its in fact awesome in support of
    me.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: