I'm using Delphi7.
GetLocaleFormatSettings(1038, FS);
FS.DecimalSeparator := '.';
FS.ThousandSeparator := #0;
FS.NegCurrFormat := 5;
FS.CurrencyString := '';
XMLNode.Text := FloatToStrF(Query.FieldByName('Quantity').AsFloat, ffGeneral, 18, 2, FS);
Quantity DB field (Firebird) is 18,2 DECIMAL.
The problem: If the value of Quantity is 15.6, sometimes FloatToStrF will give back 15.600000012 or 15.59999996 or similar. I'm putting the result into an XML file with strict validation (18,2) and it is generating an error. Restarting the computer may solve the problem.
I'm thinking this is a floating point issue, but what can I use instead of FloatToStrF to convert a decimal number to string?
Thank you!