Einzelnen Beitrag anzeigen

samso

Registriert seit: 29. Mär 2009
439 Beiträge
 
#10

AW: Datentyp "Int64" fehlerhaft?

  Alt 19. Jun 2017, 12:03
Was hältst Du von dieser Idee?


Delphi-Quellcode:
function CLZ(x: Int64): Integer;
var
  n: Integer;
begin
  if (x = 0)
  then
    Result := 64
  else begin
    n := 0;
    if (x and not $00000000FFFFFFFF)=0
    then begin
      n := n + 32;
      x := x shl 32;
    end;
    if (x and not $0000FFFFFFFFFFFF)=0
    then begin
      n := n + 16;
      x := x shl 16;
    end;
    if (x and not $00FFFFFFFFFFFFFF)=0
    then begin
      n := n + 8;
      x := x shl 8;
    end;
    if (x and not $0FFFFFFFFFFFFFFF)=0
    then begin
      n := n + 4;
      x := x shl 4;
    end;
    if (x and not $3FFFFFFFFFFFFFFF)=0
    then begin
      n := n + 2;
      x := x shl 2;
    end;
    if (x and not $7FFFFFFFFFFFFFFF)=0
    then
      n := n + 1;
    Result := n;
  end;
end;
  Mit Zitat antworten Zitat