• Delphi进制转换


    //十六进制(S)-->>十进制(I)  [重写:Jey]
    function hextoint(s: string): Integer;  
    begin           //$代表16进制
      Result:=StrToInt('$'+s);
    end;

    //十进制转换为二进制字符串  [重写:Jey]
    function inttoBin(i: integer): string; 
    begin
     while i <>0 do
     begin              //i mod 2取模,再使用format格式化
       result:=Format('%d'+result,[i mod 2]);
       i:=i div 2
     end
    end;
    //二进制(S)-->>十进制(D)    [重写:Jey]
    uses Math; 
    function hextoint(s: string): Double;
    begin
      while Length(s) <>0 do
      begin              //2^(长度-1)次方
        if s[1]='1' then  Result:=Result+power(2,Length(s)-1);
        s:=Copy(s,2,Length(s));
      end
    end;
    //十进制(I)-->>十六进制(S)
    //D自带函数,Digits长度,一般设4.
    function IntToHex(Value: Integer; Digits: Integer): string;

    //数据(S)-->>二进制(S) 
    //任何数据都是以二进制形式存储的! (转) 
    function conertde(s:string):string; 
    var 
     i:integer; 
    begin 
     for i:=1 to length(s) do 
       result:=result+inttohex(ord(s[i]),2); 
    end;

  • 相关阅读:
    Python流程控制
    Python 迭代器和列表解析
    Python 文件对象
    TF-IDF介绍
    hexo博客更换主题
    学习笔记—MapReduce
    Mac下Anaconda的安装和使用
    Flume的介绍和简单操作
    hexo+github搭建个人博客
    Hbase的安装和基本使用
  • 原文地址:https://www.cnblogs.com/easypass/p/1599185.html
Copyright © 2020-2023  润新知