
21.06.2011, 01:44
|
 |
.
|
|
Регистрация: 18.05.2011
Адрес: Омск
Сообщения: 3,970
Версия Delphi: 3,5,7,10,12,XE2
Репутация: выкл
|
|
Открываем исходники Дельфи (ValEdit.pas) и видим:
Код:
function TNumberEdit.DecToBin(aValue: LongInt): String;
var
w: Array[1..2] of Word absolute aValue;
St: String;
function BinByte(b: Byte): String;
const
Bin: Array[False..True] of Char = '01';
begin
Result := Bin[b and 128 = 128] + Bin[b and 64 = 64] + Bin[b and 32 = 32] + Bin[b and 16 = 16] +
Bin[b and 8 = 8] + Bin[b and 4 = 4] + Bin[b and 2 = 2] + Bin[b and 1 = 1];
end;
function BinWord(w: Word): String;
begin
BinWord := BinByte(Hi(w)) + BinByte(Lo(w));
end;
begin
St := BinWord(w[2]) + BinWord(w[1]);
while (St[1] = '0') and (Length(St) > 1) do
Delete(St, 1, 1);
Result := St;
end;
|