惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
T
Threatpost
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
月光博客
月光博客
V
Visual Studio Blog
T
Tailwind CSS Blog
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
Jina AI
Jina AI
J
Java Code Geeks
Martin Fowler
Martin Fowler
大猫的无限游戏
大猫的无限游戏
Recorded Future
Recorded Future
C
Check Point Blog
腾讯CDC
N
Netflix TechBlog - Medium
aimingoo的专栏
aimingoo的专栏
罗磊的独立博客
Hacker News: Ask HN
Hacker News: Ask HN
SecWiki News
SecWiki News
博客园 - Franky
Hacker News - Newest:
Hacker News - Newest: "LLM"
N
News | PayPal Newsroom
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security @ Cisco Blogs
W
WeLiveSecurity
The Last Watchdog
The Last Watchdog
Cloudbric
Cloudbric
F
Full Disclosure
The Cloudflare Blog
Y
Y Combinator Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
S
Schneier on Security
Schneier on Security
Schneier on Security
Spread Privacy
Spread Privacy
L
LINUX DO - 热门话题
AI
AI
N
News and Events Feed by Topic
T
Tor Project blog
P
Palo Alto Networks Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
G
Google Developers Blog

博客园 - 张伦

Entity Framework 自动生成代码 如何用继承 PostMessage和SendMessage有什么区别? 正则表达式之日期类型(匹配闰年) C语言随记 - 张伦 - 博客园 Modbus通讯类(Delphi) 未曾清贫难成人 Delphi中数据集导出为Excel C#sql查询导出为excel文件,并最终释放excel资源。 水晶报表ReportViewer之“创建控件错误” 什么是RFID matlab生成exe,含gui图形界面 EVC中int与string的相互转化 什么是嵌入式操作系统? WinCE和PocketPC的异同 Delphi中MSComm控件的安装(Licenses information for TMSComm not found) ARM是什么? 创建型设计模式分类 什么是设计模式? ASP.NET:创建对话框
Delphi 进制转换——十六进制 to 十进制浮点数
张伦 · 2006-08-07 · via 博客园 - 张伦

//十进制 to 二进制
function IntToBin(Value: LongInt;Size: Integer): String;
var
 i: Integer;
begin
 Result:='';
 for i:=Size-1 downto 0 do begin
    if Value and (1 shl i)<>0 then begin
       Result:=Result+'1';
  end else begin
       Result:=Result+'0';
  end;
 end;
end;

//二进制 to 十进制

function BintoInt(Value:   String):   LongInt;
  var
      i,Size:   Integer;
  begin
      Result:=0;
      Size:=Length(Value);
      for   i:=Size   downto   1   do
      begin
          if   Copy(Value,i,1)='1'   then
              Result:=Result+(1   shl   (Size-i));
      end;
  end;

  function floatBintoInt(Value:   String):   real;
  var
      i,Size:   Integer;
  begin
      Result:=0;
      Size:=Length(Value);
      for   i:=Size   downto   1   do
      begin
          if   Copy(Value,i,1)='1'   then
              Result:=Result+1/(1   shl  i);
      end;
  end;

//十六进制 to 二进制

function HextoBinary(Hex:string):string;
const
    BOX: array [0..15] of string =
         ('0000','0001','0010','0011',
          '0100','0101','0110','0111',
          '1000','1001','1010','1011',
          '1100','1101','1110','1111');
var
    i:integer;
begin
    for i:=Length(Hex) downto 1 do
        Result:=BOX[StrToInt('$'+Hex[i])]+Result;
end;

//十六进制 to 十进制 浮点型
function HextoFloat(s:string):real;
var b,temp:string;
    e:integer;
    f:real;
begin
  b:=HextoBinary(s);
  temp := copy(b,2,8);
  e:=BintoInt(temp)-127;
  temp := copy(b,10,23);
  f := 1+floatBintoInt(temp);
  if(copy(b,1,1)='0')then
    result := power(2,e)*f
  else
    result :=-power(2,e)*f;
end;