Показать сообщение отдельно
  #2  
Старый 07.09.2014, 00:22
Аватар для min@y™
min@y™ min@y™ вне форума
Заблокирован
 
Регистрация: 29.08.2014
Адрес: Рязань
Сообщения: 26
Версия Delphi: D7, CB6, etc
Репутация: 10
По умолчанию

В старой доброй RxLib есть модуль rxStrUtils.pas. В этом модуле среди кучи полезных функций есть вот такие:
Код:
function Dec2Numb(N: Longint; A, B: Byte): string;
{ Dec2Numb converts the given value to a string representation with the
  base equal to B and with the minimum number of digits (A) specified. }

function Numb2Dec(S: string; B: Byte): Longint;
{ Numb2Dec converts the given B-based numeric string to the corresponding
  integer value. }

function IntToBin(Value: Longint; Digits, Spaces: Integer): string;
{ IntToBin converts the given value to a binary string representation
  with the minimum number of digits specified. }
У меня есть и свои юношеские наработки по этому поводу. Могу прислать. Например:
Код:
{ Пpеобpазует целое число N в число по основанию B,
  дополняя слева нулями до длины A и вставляя пробелы
  через каждые С символов (0 - не вставляет).}
function AdvancedDec2Numb(const N: Integer; const A, B, C: Byte): string;
var
  i, Len: Integer;
  S: string;
begin
  Result:= '';
  S:= Dec2Numb(N, A, B);
  Len:= Length(S);

  if C > 0
    then begin
           for i:= Len downto 1 do
             begin
               Result:= S[i] + Result;
               if (Len - i + 1) mod C = 0
                 then Result:= ' ' + Result;
             end;
           Result:= Trim(Result);
         end
    else Result:= S;
end;
Ответить с цитированием