16进制字符串s:=8B 6B 36 33;怎么让它每个字节减16进制33,就是8B-33,6B-33……再反过来合并,即00033858,再除以100得到338.58??急用~~

解决方案 »

  1.   

    记住几个函数ord、chr即可
    其他的for循环 
      

  2.   

    procedure TForm1.FormCreate(Sender: TObject);
    var
      S: string;
      Buf: array[0..MAXBYTE-1] of Char;
      iLen, I, iSum: Integer;
    begin
      S := '8B 6B 36 33';  S := StringReplace(S, ' ', '', [rfReplaceAll]);
      FillChar(Buf, MAXBYTE, 0);
      iLen := HexToBin(@S[1], Buf, MAXBYTE);  iSum := 0;
      for I := 0 to iLen - 1 do
      begin
        Buf[I] := Chr(Ord(Buf[I]) - $33);
        Inc(iSum, Ord(Buf[I]) shl (8 * I))
      end;  ShowMessage(FloatToStr(iSum / $100))
    end;
      

  3.   


    procedure TForm1.Button1Click(Sender: TObject);
    var
      X, Z : string;
      Y, I: Integer;
      B: Byte;
    begin
      X := '8B6B3633';
      Y := StrtoInt('$'+X) - StrtoInt('$'+'33333333');
      Showmessage(Format('%.4x',[Y]));
      Z := '';
      for I := 0 to 3 do begin
        B := Y shr (8*I);
        Z := Z + Format('%.2x', [B]);
      end;
      Showmessage(Z);
    end;
    //除以100的事,自己做吧
      

  4.   

    var
      s: string;
      v: integer;
      fv: double;
    begin
      s := '8B6B3633';
      v := StrToInt('$'+ s) - StrToInt('$33333333');
      BinToHex(@v, @s[1], 4);
      fv := StrToInt(s) / 100;
      ShowMessage(FloatToStr(fv));
    end;
      

  5.   


    var
      s: integer;
    begin
      asm
        mov eax, $8B6B3633 - $33333333
        bswap eax
        mov s,eax
      end;
      ShowMessage(FloatToStr(s / $100));
    end;
      

  6.   

    楼上请看清楚LZ问题,是16进制字符串“8B6B3633”
      

  7.   


    转换一下不结了么
    var
      sd: string;
      s: integer;
    begin
      sd := '8B6B3633';
      s := strtoint('$' + sd) - $33333333;
      asm
        mov eax,s
        bswap eax
        mov s,eax
      end;
      ShowMessage(FloatToStr(s / $100));
    end;