The problem is that the data type "double" (and "single" and "extended" as well) has only a given number of bits to represent a number. Only numbers which can be expressed as a combination of powers of 2 are exact, for anything else the closest combination of powers of 2 is used. Expressed with extreme words. The exact number 0.47875 simply does not "exist" in the computer.
In most calculations, ultimate accuracy as offered by big-number libraries is not needed (and even they cannot express the result of 1/3 in an "exact" way because this would require an infinite number of decimal places). Your issue is not the precision of the numbers (which will almost never be "exact"), but the way how these numbers are displayed. And for this you only need to use the correct formatting functions.
You should specify in your calculator application the maximum number of decimal places and then format every numeric output to it. When, for example, there is a maximum of 6 decimal places, you should format the calculation result x by FormatFloat('0.######', x) or by Format('%.6g', [ x ]):
program Project1;
uses
SysUtils;
var
x: Double;
begin
x := 32.47875-32;
WriteLn(x);
WriteLn(FormatFloat('0.######', x));
WriteLn(Format('%.6g', [x]));
WriteLn;
x := 1.0/3;
WriteLn(x);
WriteLn(FormatFloat('0.######', x));
WriteLn(Format('%.6g', [x]));
WriteLn;
x := 2.5+0.1;
WriteLn(x);
WriteLn(FormatFloat('0.######', x));
WriteLn(Format('%.6g', [x]));
WriteLn;
ReadLn;
end.
Output:
4.7875000000000001E-001
0.47875
0.47875
3.3333334326744080E-001
0.333333
0.333333
2.6000000000000001E+000
2.6
2.6You could also use the format string '0.000000' for FormatFloat and '%.6f' for Format to get also nice rounding, but this would add unnecessary zeros as decimals.