var F,F1: Double; begin F := 12.34678; F1 := Round(Trunc(F*1000)/10)/100; //=12.35 ShowMessage(FloatToStr(F1)); end;————————————————————————————————— 宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。 —————————————————————————————————
给你一个函数:function FourOutFiveIn(xValue:Double; xpos:integer):Double; begin if xValue < 0 then Result := int( xValue * exp( xPos * ln(10)) - 0.5) / exp( xPos * ln(10)) else Result := int( xValue * exp( xPos * ln(10)) + 0.5) / exp( xPos * ln(10)); end;
F,F1: Double;
begin
F := 12.34678;
F1 := Round(Trunc(F*1000)/10)/100; //=12.35
ShowMessage(FloatToStr(F1));
end;—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
begin
if xValue < 0 then
Result := int( xValue * exp( xPos * ln(10)) - 0.5) / exp( xPos * ln(10))
else
Result := int( xValue * exp( xPos * ln(10)) + 0.5) / exp( xPos * ln(10));
end;