zoukankan      html  css  js  c++  java
  • 十六进制数相加校验和计算程序

    {-------------------------------------------------------------------------------
      过程名:    16进制数相加效验和程序
      作者:      陈新光
      日期:      2008.07.24
      参数:      AStr: string; AIndex: Integer(从第几个字符开始计算)
      返回值:    string
    -------------------------------------------------------------------------------}
    function GetCheckStr(AStr: string; AIndex: Integer): string;
    var
      newstr1,he,oldstr:string;
      tj:boolean;
      i:integer;
    begin
       i:=1;
       he:='';
       tj:=true;
      oldstr:=copy(AStr,AIndex,length(AStr)-AIndex+1);
      while tj=true do
        begin
          newstr1:=copy(oldstr,i,2);
          oldstr:=copy(oldstr,i+2,length(oldstr)-2);
          //开始计算校验和并给he变量
          if he='' then
            begin
              he:=inttohex(strtointdef('$'+newstr1,16)+ strtointdef('$'+'00',16),2);
              he:=rightstr(he,2);
            end
          else
            begin
              he:=inttohex(strtointdef('$'+newstr1,16)+ strtointdef('$'+he,16),2);
              he:=rightstr(he,2);
            end;
          if  length(oldstr) =0 then tj:=false;
        end;
      Result:= AStr+he;
    end;
  • 相关阅读:
    Verilog杂谈
    Hadoop家族学习路线图
    R语言中apply函数
    R语言数组array函数
    R语言列表list函数
    R语言多元素向量
    R语言提取字符串的一部分substring函数
    R语言改变大小写 toupper()和 tolower()函数
    R语言统计字符串的字符数ncahr函数
    R语言格式化数字和字符串format函数
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940846.html
Copyright © 2011-2022 走看看