Bart,
Thank you for opening a ticket, but I think the title and the "workaround" are misleading. Actually it is the other way round. WriteFloat can
NOT write MaxValue out correctly. It is rounded to 14 decimals, i.e. 1.79769313486232E308, what is really more than MaxValue and hence the ReadFloat has all the right to refuse it in the form of Float Overflow.
Writeln(tDoubleHelper.MaxValue) writes out 16 decimals, i.e. 1.7976931348623157E+308 and basically that is the maximum precision driven by the 52 bits used to indicate the decimals for a double value.
What can be done to test it, is to run my program and as you also saw, it writes out the 14 digit version.
Now we can play with the ini file with any text editor. If I change it to the number you suggest in the workaround, it will work but incorrectly. Seemingly it works, because the written number can be read back, but it will be incorrect, not being equal to MaxValue (actually the reason, why people often use MaxValue as a synonym to invalid value). Your workaround only works, because the number you suggested has a last digit of 1, when written to the ini file rounded to 14 decimals. And that number is indeed smaller than MaxValue, so can be read (but not equal).
However if we manually change the ini file to the 16 decimal version, then ReadFloat can still read it AND it also finds it equal to MaxValue, as this number is binary converted to the same 64 bit representation as MaxValue is stored internally.
So the only error I think is that WriteFloat writes 14 digits and not the necessary 16 bits. I think I even found the error. It is in sysstr.inc line number 1734, where there is a hard coded 15 precision (1. + 14 decimals?) and if it was 17 then probably the number would be written with enough decimals. However that is a read only include file and FloatToStrFIntl cannot be called directly, so I could not call it with the right precision, but could mimic it with the str procedure used inside FloatToStrIntl and it works. So the bug is extremely easy to fix, just change line 1734 from 15 to 17.
Also, WriteFloat might write an Extended value, in which case also 15 is hardcoded in line 1704. There probably an even higher number should replace the 15. Sorry, WriteFloat can only handle Double (os it probably should be called WriteDouble(), but for other uses of FloatToStr the crossed-out sentence is still correct. There 14 decimals (Precision 15) is far too low.
I used the very simple program to test it:
var
IniFile : tIniFile;
MaxFloat : double;
s : string;
begin
writeln(tDoubleHelper.MaxValue);
IniFile := tIniFile.Create('test.ini');
MaxFloat := IniFile.ReadFloat('test', 'maxfloatasstring', tDoubleHelper.MaxValue);
writeln(MaxFloat, ' ', tDoubleHelper.MaxValue, ' ', MaxFloat=tDoubleHelper.MaxValue);
MaxFloat := IniFile.ReadFloat('test', 'maxfloat', tDoubleHelper.MaxValue); // << crash here at the second run
writeln(MaxFloat, ' ', tDoubleHelper.MaxValue, ' ', MaxFloat=tDoubleHelper.MaxValue);
Str(Double(Extended(Aligned(tDoubleHelper.MaxValue))):17+7, s);
IniFile.WriteString('test', 'maxfloatasstring', s);
IniFile.WriteFloat('test', 'maxfloat', tDoubleHelper.MaxValue);
IniFile.Free;
end.