function MyRound(P: Double; Decimals: integer): Double;
var
  s: string;
begin
  s := FloatToStrF(P, ffFixed, 15, Decimals);
  Result := StrToFloat(s);
end;function IntDate(T: TDateTime): Integer;
var
  Year, Month, Day: Word;
begin
  DecodeDate(T, Year, Month, Day);
  Result := Year * 10000 + Month * 100 + Day;
end;

解决方案 »

  1.   


    //p 原始浮点数
    //Decimals有效小数位
    //比如 MyRound(20.3201734,4);
    //返回的值为20.3202。
    function MyRound(P: Double; Decimals: integer): Double;
    var
      s: string;
    begin
      s := FloatToStrF(P, ffFixed, 15, Decimals);
      Result := StrToFloat(s);
    end;
    //其它他的功能很简单只是把年月日这三个无素,组合成一个integer数字
    //如传入2011/12/2 而返回的是20111202
    //它的功能和_IntDate函数一样。
    function IntDate(T: TDateTime): Integer;
    var
      Year, Month, Day: Word;
    begin
      DecodeDate(T, Year, Month, Day);
      Result := Year * 10000 + Month * 100 + Day;
    end;function _IntDate(T:TDateTime):Integer;
    var
      s:string;
    begin
      s := FormatDateTime('yyyymmdd',t);
      Result := StrToInt(s);
    end;