The majority of the rounding can be done via Delphi's "Format" function (it doesn't handle the sign check, but you can do this separately).

It has slightly different format of the second parameter, but you can use something like:

Code:
Text:= Format('%1.4f', [2.345699]); // rounds to 2.3457
You can check the documentation for the format function - it has more options for specifying floating point numbers, perhaps you can adapt several variations of this function to simulate the Excel's one.