Title: How to round numbers to a predetermined number of decimals
function Rounder(var Value: Double; Decimals: Integer): Double;
var
j: Integer;
A: Double;
begin
A := 1;
case Decimals of
0: A := 1;
1: A := 10;
else
for j := 1 to Decimals do
A := A * 10;
end;
Result := Int((Value * A) + 0.5) / A;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Value: Double;
begin
Value := 23.56784;
//Result is 23.57
label1.Caption := FloatToStr(Rounder(Value, 2));
end;