But be warned: Rounding numbers is a risky job, you may not get what you want because the rounded number can be subject to rounding errors in the same way as the input number.
It all boils down to the question: Is the number a combination of powers of 2 (1, 0.5, 0.25, 0.125, ...)? If this is not the case, then the exact number does not exist in the (binary) computer! The computer works with the nearest combination of powers of 2 instead, and this results in lots of 0s or 9s at the end of the displayed value.
Suppose the number 0.100001. You want to round it to 1 decimal place and are expecting the value 0.1. But 0.1 is 1 / (2*5) - the 5 in there is not a power of 2, and therefore the value 0.1 does not "exist" exactly ... And when you call SimpleRoundTo the result will not be 0.1, but 0.1000000000000000000001 (maybe the count of 0s is not correct).
See this simple project:
program Project1;
uses
SysUtils, Math;
var
x, y: Double;
begin
x := 0.100001;
y := SimpleRoundTo(x, -1);
WriteLn('x = ', x, ', y = ', y, ', y = 0.1? ', BoolToStr(y=0.1, true));
ReadLn;
end.
There are really not many reasons why numbers should be rounded to numbers (Round, RoundTo, SimpleRoundTo, except for rounding to integers). What's much more important is rounding of numbers for string representation. Here you have the FloatToStr, FormatFloat, Str etc. routines, and they handle rounding in a much more natural way.