mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 21:49:09 +02:00
* Spaces version improved.
git-svn-id: trunk@8780 -
This commit is contained in:
parent
f66916fc95
commit
a43e03f6c0
@ -1304,21 +1304,40 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$implicitexceptions off}
|
||||||
function intToBin(Value: Longint; Digits, Spaces: Integer): string;
|
function intToBin(Value: Longint; Digits, Spaces: Integer): string;
|
||||||
|
var endpos : integer;
|
||||||
|
p,p2:pchar;
|
||||||
|
k: integer;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
if (Digits>32) then
|
if (Digits>32) then
|
||||||
Digits:=32;
|
Digits:=32;
|
||||||
while (Digits>0) do
|
if (spaces=0) then
|
||||||
|
begin
|
||||||
|
result:=inttobin(value,digits);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
endpos:=digits+ (digits-1) div spaces;
|
||||||
|
setlength(result,endpos);
|
||||||
|
p:=@result[endpos];
|
||||||
|
p2:=@result[1];
|
||||||
|
k:=spaces;
|
||||||
|
while (p>=p2) do
|
||||||
begin
|
begin
|
||||||
if (Digits mod Spaces)=0 then
|
if k=0 then
|
||||||
Result:=Result+' ';
|
begin
|
||||||
Dec(Digits);
|
p^:=' ';
|
||||||
Result:=Result+intToStr((Value shr Digits) and 1);
|
dec(p);
|
||||||
end;
|
k:=spaces;
|
||||||
|
end;
|
||||||
|
p^:=chr(48+(cardinal(value) and 1));
|
||||||
|
value:=cardinal(value) shr 1;
|
||||||
|
dec(p);
|
||||||
|
dec(k);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$implicitexceptions off}
|
|
||||||
function intToBin(Value: Longint; Digits:integer): string;
|
function intToBin(Value: Longint; Digits:integer): string;
|
||||||
var p,p2 : pchar;
|
var p,p2 : pchar;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user