这是在数据库里面的,程序要求数据库里的‘单价’字段的小数点后要6位小数,我在录入8位小数位后,程序本应显示小数点后6位数值,对第7位进行四舍五入。可程序却只有显示小数点后四位,后2位自动赋为00,我是这样设的(单价是一个数据库字段,为FLoat型):
  ‘单价’ DisplayFormat='#0.000000'
请大家指点

解决方案 »

  1.   

    不会吧,在代码里找到单价的那个字段,看一它的类型,四位好象是TBCDField吧,不记得了,如果要是别的类型,你手工给它改成TFloatField应该可以,如果就是TFloatField,那俺就不知道了。
      

  2.   

    //两个参数,第一个是输入一个Currency类型,第二个参数是输入你要保留几位小数。function ReturnMore(input : Currency; Leng : Integer) : String;
    var
      w,iLoop,iLeng : Integer;
      cDec : Currency;
      s,str,sDec : String;
    begin
      w := pos('.',FloatToStr(input));
      if Leng = 0 then
      begin
        Result := copy(FloatToStr(input),1,w-1);
      end
      else
      begin
        if w = 0 then
        begin
          sDec := '';
          for iLoop := 0 to Leng-1 do
          begin
            sDec := sDec+'0';
          end;
          result := FloatToStr(input)+'.'+sDec;
        end
        else
        begin
          s := copy(FloatToStr(input),1,w+Leng);
          iLeng := Length(trim(copy(s,w+1,Leng)));
          if copy(s,w+Leng,1) = '' then
          begin
            sDec := '';
            for iLoop := 0 to Leng-iLeng-1 do
            begin
              sDec := sDec+'0';
            end;
            result := FloatToStr(input)+sDec;
          end
          else
          begin
            str := copy(FloatToStr(input),w+Leng+1,1);
            if str <> '' then
            begin
              if StrToFloat(str) >=5 then
              begin
                cDec := 1;
                for iLoop := 0 to Leng-1 do
                begin
                  cDec := cDec/10;
                end;
                result := FloatToStr(StrToFloat(s)+cDec);
              end
              else
                result := s;
            end
            else
              Result := FloatToStr(input);
          end;
        end;
      end;
    end;
      

  3.   

    谢谢大家,这个问题我已经解决了。我把类型改为REAL,然后 DISPLAYFORMAT=‘#0.000000',搞定!!!