谢了.

解决方案 »

  1.   

    BCD码除以16,商和余数就是了!
      

  2.   

    Matrix32中有个Function BCDToString(const BCDValue: TBCDNumber): string;
    你看看这个行不行
      

  3.   

    // Binary to Integer function BinToInt(Value: string): Integer; 
    var 
      i, iValueSize: Integer; 
    begin 
      Result := 0; 
      iValueSize := Length(Value); 
      for i := iValueSize downto 1 do 
        if Value[i] = '1' then Result := Result + (1 shl (iValueSize - i)); 
    end; 
    把一个整数变成二进制字符串
    function IntToBinaryStr(TheVal: LongInt): string;
    var
      counter: LongInt;
    begin
    {This part is here because we remove leading zeros.  That
    means that a zero value would return an empty string.}  if TheVal = 0 then begin
        result := '0';
        exit;
      end;  result := '';
      counter := $80000000;  {Suppress leading zeros}
      while  ((counter and TheVal) = 0) do begin
        counter := counter shr 1;
        if (counter = 0) then break; {We found our first "1".}
      end;  while counter > 0 do begin
        if (counter and TheVal) = 0 then result := result + '0'
        else  result := result + '1';
        counter := counter shr 1;
      end;
    end;
      

  4.   

    我的不是转为二进制字符串,而是把一个字符串转为用BCD编码过的的字符串.要能互相转换的.谢谢了,各位继续帮忙.
      

  5.   

    说一下思路,BCD码主要是十进制用的,如果是非数字字符串的话,是不可能的,只能转换为十进制数,转换方法为4位二进制的BCD码等于一位十进制数字,然后自己编函数即可