小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Delphi 下的各個進制轉(zhuǎn)換函數(shù)

 delphi_筆記 2019-09-19
//十進制 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..15of 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;

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多