In TestJsonDataObjects.pas, in procedure TestTJsonBaseObject.TestVariant, there's a call to CompareFloatRelative().
I have searched the Net and all my code repo (of about 20 years) and I couldn't find it.
It turns out it exists in XE10 (and maybe in other versions above XE2, I didn't check) and since it is MPL licensed, I am copying the relevant code below --in case anyone else needs it.
BTW, these are overloaded.
function CompareFloatRelative(expected, actual: Extended) : Boolean;
begin
Result := CompareFloatRelative(expected, actual, 0.0000001); //This is a 99.99999% accuracy
end;
function CompareFloatRelative(expected, actual: Extended; RelativeError : Extended) : Boolean;
begin
Result := False;
if expected = actual then := True
else if abs((actual - expected) / expected) < RelativeError then Result := True;
end;
In TestJsonDataObjects.pas, in procedure TestTJsonBaseObject.TestVariant, there's a call to CompareFloatRelative().
I have searched the Net and all my code repo (of about 20 years) and I couldn't find it.
It turns out it exists in XE10 (and maybe in other versions above XE2, I didn't check) and since it is MPL licensed, I am copying the relevant code below --in case anyone else needs it.
BTW, these are overloaded.