[fpc-devel] tbits.NotBits
Mattias Gaertner
nc-gaertnma at netcologne.de
Thu Apr 13 11:47:00 CEST 2017
On Thu, 13 Apr 2017 11:28:20 +0200
Andrea Mauri <andrea.mauri.75 at gmail.com> wrote:
>[...]
> procedure TBits.Setall;
> var
> loop : longint;
> begin
> for loop := 0 to FSize - 1 do
> FBits^[loop] := 1;
Should be
FBits^[loop] := not cardinal(0);
> end;
Btw, it seems TBits misses an AssignBits(b: TBits).
And maybe an AssignNotBits(b: TBits)
> 2. a Not operator, something like a.NotBits; with no arguments that
> perform the not operation on the TBIts instance (a[i]:= not a[i]) or
> something that performs a not operation on the passed TBits, i.e.
> a.Not(b) that fills a in this way: a[i]:= not b[i];
>
> procedure TBits.Notbits;
> var
> n : longint;
> jj : cardinal;
> loop : longint;
> begin
> for loop := 0 to FSize - 1 do
> FBits^[loop] := not FBits^[loop];
> end;
>
> or
>
> procedure TBits.Not(bitset : TBits);
"Not" is a preserved word.
> var
> n : longint;
> loop : longint;
> begin
> if FSize < bitset.getFSize then
> n := FSize - 1
> else
> n := bitset.getFSize - 1;
>
> for loop := 0 to n do
> FBits^[loop] := not bitset.FBits^[loop];
> end;
For consistency with the other SomethingBits methods you must handle all
bits, not just the start.
Mattias
More information about the fpc-devel
mailing list