|
|
Функция
перевода числа в бинарное число (записанное в строке)
Обратная
операция делается функцией BinToLongWord
function LongWordToBin(val:LongWord;count:byte):string;
begin
result:='';
if count>0 then
begin
if val and $00000001>0 then result:='1'+result else result:='0'+result;
if val and $00000002>0 then result:='1'+result else result:='0'+result;
if val and $00000004>0 then result:='1'+result else result:='0'+result;
if val and $00000008>0 then result:='1'+result else result:='0'+result;
if val and $00000010>0 then result:='1'+result else result:='0'+result;
if val and $00000020>0 then result:='1'+result else result:='0'+result;
if val and $00000040>0 then result:='1'+result else result:='0'+result;
if val and $00000080>0 then result:='1'+result else result:='0'+result;
end;
if count>1 then
begin
if val and $00000100>0 then result:='1'+result else result:='0'+result;
if val and $00000200>0 then result:='1'+result else result:='0'+result;
if val and $00000400>0 then result:='1'+result else result:='0'+result;
if val and $00000800>0 then result:='1'+result else result:='0'+result;
if val and $00001000>0 then result:='1'+result else result:='0'+result;
if val and $00002000>0 then result:='1'+result else result:='0'+result;
if val and $00004000>0 then result:='1'+result else result:='0'+result;
if val and $00008000>0 then result:='1'+result else result:='0'+result;
end;
if count>2 then
begin
if val and $00010000>0 then result:='1'+result else result:='0'+result;
if val and $00020000>0 then result:='1'+result else result:='0'+result;
if val and $00040000>0 then result:='1'+result else result:='0'+result;
if val and $00080000>0 then result:='1'+result else result:='0'+result;
if val and $00100000>0 then result:='1'+result else result:='0'+result;
if val and $00200000>0 then result:='1'+result else result:='0'+result;
if val and $00400000>0 then result:='1'+result else result:='0'+result;
if val and $00800000>0 then result:='1'+result else result:='0'+result;
end;
if count>3 then
begin
if val and $01000000>0 then result:='1'+result else result:='0'+result;
if val and $02000000>0 then result:='1'+result else result:='0'+result;
if val and $04000000>0 then result:='1'+result else result:='0'+result;
if val and $08000000>0 then result:='1'+result else result:='0'+result;
if val and $10000000>0 then result:='1'+result else result:='0'+result;
if val and $20000000>0 then result:='1'+result else result:='0'+result;
if val and $40000000>0 then result:='1'+result else result:='0'+result;
if val and $80000000>0 then result:='1'+result else result:='0'+result;
end;
end;
|
|