bok
2013-06-25 07:40:06 UTC
Can anyone tell me if either version of this fx is preferable over the other?
------WHEN------
1. compiled with Delphi XE2
2. handling approx 10MB files
3. Machine: Win7(64bit) 4 year old AMD dual core processor and 2 GB memory
////////////////////////////////////////////////////////////
function ReverseBits1(b: Byte): Byte;
var
x: Integer;
begin
Result := 0;
for x := 0 to 7 do Result := (Result shl 1) or ((b shr x) and 1);
end;
function ReverseBits2(b: Byte): Byte;
var
x: Integer;
begin
Result := 0;
for x := 1 to 8 do
begin
Result := (Result shl 1) or (b and 1);
b := b shr 1;
end;
end;
Thanks
------WHEN------
1. compiled with Delphi XE2
2. handling approx 10MB files
3. Machine: Win7(64bit) 4 year old AMD dual core processor and 2 GB memory
////////////////////////////////////////////////////////////
function ReverseBits1(b: Byte): Byte;
var
x: Integer;
begin
Result := 0;
for x := 0 to 7 do Result := (Result shl 1) or ((b shr x) and 1);
end;
function ReverseBits2(b: Byte): Byte;
var
x: Integer;
begin
Result := 0;
for x := 1 to 8 do
begin
Result := (Result shl 1) or (b and 1);
b := b shr 1;
end;
end;
Thanks