如:010000001001111011110000
转换成1980

解决方案 »

  1.   

    01000000 10011110 11110000 
    三个Byte,双精度是四个字节哈
    有什么规律吗?手工怎么转
      

  2.   

    先转16,再从16转成10
    010000001001111011110000 这个转出来是 409EF0然后再将409EF0放到Double里,出来就是1980了00 00 00 00 00 F0 9E 40 = 1980
      

  3.   

    倒,双精度是8个字节,内存中这样存放00000000 00000000 00000000 00000000 00000000 11110000 10011110 01000000
    pos----0--------1--------2--------3--------4--------5--------6--------7 参考如下代码:var
      D: Double;
      I: Integer;
      S: string;
      vByte, vBit: Integer;
    begin
      S := '010000001001111011110000';
      D := 0;
      vByte := 7; // 字节从一开始 
      vBit := 7;
      for I := 1 to Length(S) do
      begin
        if S[I] <> '0' then
          Byte(PChar(@D)[vByte]) := Byte(PChar(@D)[vByte]) or (1 shl vBit);
        Dec(vBit);
        if vBit < 0 then
        begin
          vBit := 7;
          Dec(vByte);
          if vByte < 0 then Break;
        end;
      end;
      Caption := FloatToStr(D);
    end;