不用"转"成二进制,计算机本来就是二进制,
直接
(x and y)

解决方案 »

  1.   

    Hex->IntegerSolution 1 
    var
      i : integer
      s : string;
    begin
      s := '$' + ThatHexString;
      i := StrToInt(a);
    end;Solution 2 
    CONST HEX : ARRAY['A'..'F'] OF INTEGER = (10,11,12,13,14,15);
    VAR str : String;
        Int,
        i   : integer;
    BEGIN
      READLN(str);
      Int := 0;
      FOR i := 1 TO Length(str) DO
        IF str[i] < 'A' THEN Int := Int * 16 + ORD(str[i]) - 48
        ELSE Int := Int * 16 + HEX[str[i]];
      WRITELN(Int);
      READLN;
    END.Dec->HexHexString := Format('%0x',DecValue);
    Ascii->Hexunit Hexstr;
    interfaceuses String16, SysUtils;Type PByte = ^BYTE;
    procedure BytesToHexStr(var hHexStr: String; pbyteArray: PByte; InputLength: WORD);
    procedure HexStrToBytes(hHexStr: String; pbyteArray: Pointer);
    procedure HexBytesToChar(var Response: String; hexbytes: PChar; InputLength: WORD);implementationprocedure BytesToHexStr(var hHexStr: String; pbyteArray: PByte; InputLength: WORD);
    Const    
     HexChars : Array[0..15] of Char = '0123456789ABCDEF';
    var    
     i, j: WORD;
    begin 
     SetLength(hHexStr, (InputLength * 2));
     FillChar(hHexStr, sizeof(hHexStr), #0); j := 1;
     for i := 1 to InputLength  do 
     begin
        hHexStr[j] := Char(HexChars[pbyteArray^ shr  4]); inc(j);
        hHexStr[j] := Char(HexChars[pbyteArray^ and 15]); inc(j);
        inc(pbyteArray); 
     end;
    end;procedure HexBytesToChar(var Response: String; hexbytes: PChar; InputLength: WORD);
    var 
     i: WORD; 
     c: byte;
    begin 
     SetLength(Response, InputLength);
     FillChar(Response, SizeOf(Response), #0);
     for i := 0 to (InputLength - 1) do 
     begin   
       c := BYTE(hexbytes[i]) And BYTE($f);
       if c > 9 then     Inc(c, $37)   else     Inc(c, $30);
       Response[i + 1] := char(c); 
     end;{for}
    end;
    procedure HexStrToBytes(hHexStr: String; pbyteArray: Pointer);
    {pbyteArray must point to enough memory to hold the output}
    var 
     i, j: WORD;
     tempPtr: PChar; 
     twoDigits : String[2];
    begin 
     tempPtr := pbyteArray; 
     j := 1;
     for i := 1 to (Length(hHexStr) DIV 2) do 
     begin
       twoDigits := Copy(hHexStr, j, 2); 
       Inc(j, 2);
       PByte(tempPtr)^ := StrToInt('$' + twoDigits);
       Inc(tempPtr); 
     end;{for}
    end;end.UNIT String16.
    interface
    {$IFNDEF Win32}
      procedure SetLength(var S: string; Len: Integer);
      procedure SetString(var Dst: string; Src: PChar; Len: Integer);
    {$ENDIF}
    implementation
    {$IFNDEF Win32}
      procedure SetLength(var S: string; Len: Integer);
      begin
        if Len > 255 then
          S[0] := Chr(255)
        else
          S[0] := Chr(Len)
      end;  procedure SetString(var Dst: string; Src: PChar; Len: Integer);
      begin
        if Len > 255 then
          Move(Src^, Dst[1], 255)
        else
          Move(Src^, Dst[1], Len);
        SetLength(Dst, Len);
      end;
    {$ENDIF}
    end.Char To ASCII
       
           ord('A') = 65ACSII to Char      chr(65) = 'A'