乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      delphi 進(jìn)制轉(zhuǎn)換 10進(jìn)制 2進(jìn)制 16進(jìn)制 hex

       獨(dú)孤求財(cái) 2012-03-20

      delphi 進(jìn)制轉(zhuǎn)換 10進(jìn)制 2進(jìn)制 16進(jìn)制 hex

      時(shí)間:2011-5-26來(lái)源:yang 作者: peng點(diǎn)擊: 71次

      一、完全用API完成:..uses Windows;
      function IntToStr(I: integer): string;
      begin
         Str(I, Result);
      end;

      function StrToInt(S: string): integer;
      begin
      Val(S, Result, Result);
      end;

      function HexToInt(Const HexValue: String) : Integer;
      begin
         Val(‘$‘+HexValue, Result, Result);
      end;

      function IntToHex(Const Value: Integer): string;
      const
         HexChars: array[0..15] of Char = ‘0123456789ABCDEF‘;
      var
         iTemp: Integer;
         i: Integer;
      begin
         Result := ‘‘;
         i := 0;
         while i<4 do
         begin
           case i of
             0: iTemp := Value shr 24 and $FF;
             1: iTemp := Value shr 16 and $FF;
             2: iTemp := Value shr 8 and $FF;
             3: iTemp := Value and $FF;
           end;
           Result := Result + HexChars[iTemp div 16];
           Result := Result + HexChars[iTemp mod 16];
           Inc(i);
         end;
      end;

      function LowerCase(const S: string): String;
      begin
         Result:=CharLower(Pchar(S));
      end;

      function UpperCase(const S: string): String;
      begin
         Result:=CharUpper(Pchar(S));
      end;

      二、函數(shù)實(shí)現(xiàn)

      //十進(jìn)制 to 二進(jìn)制
      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;

      //二進(jìn)制 to 十進(jìn)制

      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;

      //十六進(jìn)制 to 二進(jìn)制

      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;

      //十六進(jìn)制 to 十進(jìn)制 浮點(diǎn)型
      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;

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

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶(hù) 評(píng)論公約

        類(lèi)似文章 更多