hjy : integer; 
hjy2 : string; hjy2 := inttohex(hjy,4); 假如hjy2得到的结果是 1A 01,那如果我现在要得到hjy2的高字节和低字节,好办,分别为 1A 01 
那现在的问题是假如hjy2得到的结果是 00 01 1A 01,叫法是不是溢出?不管了,那如果我现在要得到hjy2的高字节和低字节,怎么取啊,不会还是 1A 01 吧,前面所谓溢出的 00 01 不管了吗?

解决方案 »

  1.   

    确认你操作的对象是什么
    hjy2是截后的,你认为还要管吗?
      

  2.   


    Longint -2147483648..2147483647
    DELPHI 中INT 与LONGINT相同,是三十二位
    00 01 1A 01是72193,哪溢出了?把问题描述清楚
      

  3.   

    procedure TForm11.btn1Click(Sender: TObject);
    const
      Test : DWORD = $12345678;
    var
      pBytes : PByteArray;
    begin
    //  取低字节
      ShowMessage(Format('lowByte = %s',[IntToHex(Lo(Test), 1)]));
    //  取高字节
      ShowMessage(Format('hiByte = %s',[IntToHex(Hi(Test), 1)]));
    //  取低字
      ShowMessage(Format('lowWord = %s',[IntToHex(LoWord(Test), 1)]));
    // 取高字
      ShowMessage(Format('hiWord = %s',[IntToHex(HiWord(Test), 1)]));
    // 在内存里从低向高分别取Dword类型字节码
      pBytes := @Test;
      ShowMessage(Format('byte1 = %s', [Inttohex(pBytes^[0],1)]));
      ShowMessage(Format('byte2 = %s', [Inttohex(pBytes^[1],1)]));
      ShowMessage(Format('byte3 = %s', [Inttohex(pBytes^[2],1)]));
      ShowMessage(Format('byte4 = %s', [Inttohex(pBytes^[3],1)]));
    end;
      

  4.   

    IntToHex(Value: Integer; Digits: Integer): string; overload; 
    hjy2 := inttohex(hjy,4); 
    你这里指定的4是在hjy不足4位的情况下才起作用的(补足4位),如果超过4位你是不用去理会它的。同时它也并不是什么溢出。对应取高低字节和原来4位的取法是一样的。 
    用hi(hjy2),lo(hjy2)可以取得对应的高低字节,hiword(hjy2),loword(hjy2)可以取得对应的高低字。