如何将一个Longint转为二进制字符串,反过来呢?如何取一个字符串前x个字符,中间x个字符和最后x个字符?谢谢!

解决方案 »

  1.   

    inttohex,hextobin,可否说得具体一些?谢谢!!
      

  2.   

    整型转换为二进制字符串:
    BinToStr(IntToBin(i)),反过来就是StrToInt(S)此时,s可以为二进制或十六进制的字符串,都可以的(具体是什么形式的我也不知道,从帮助文件中查的)取字符串前X个字符:function LeftStr(const AText: string; ACount: Integer): string;中间: copy(String,Astart,ALength),
    最后X个:RightStr(st: String; Len: Integer): String;
      

  3.   

    我又试了一下,StrToInt(S)不能将十六进制数转换到字符型,是不是delphi 的帮助文件写错了?
    这是它的原文:
    function StrToInt(const S: string): Integer;DescriptionStrToInt converts the string S, which represents an integer-type number in either decimal or hexadecimal notation, into a number. If S does not represent a valid number, StrToInt raises an EConvertError exception.
      

  4.   

    用DateTimeToStr将时间转化为字符串,那么如何比较两个时间的早晚呢?
      

  5.   

    建你将时间转成“YYYY-MM-DD”形式,结构统一后,就好比较了!
      

  6.   

    续:为何要转成字符后再比较呢?直接比较不行吗?datetime也是个数啊!