(single, single) overload is preferred to (double, double) when actual types are (double, any integer)
The following program:
{$mode objfpc} {$longstrings+} {$warn 5024 off Parameter not used}
uses
Math;
const
X = double(51.354860533067);
function maxov(a, b: single): string; begin result := 'max(single, single)'; end;
function maxov(a, b: double): string; begin result := 'max(double, double)'; end;
begin
writeln('X =', X);
writeln;
writeln('max(X, 0) = ', maxov(X, 0), ' =', max(X, 0));
writeln('max(X, single(0)) = ', maxov(X, single(0)), ' =', max(X, single(0)));
writeln('max(X, double(0)) = ', maxov(X, double(0)), ' =', max(X, double(0)));
writeln('max(double(X), 0) = ', maxov(double(X), 0), ' =', max(double(X), 0));
writeln;
writeln('max(0, X) = ', maxov(0, X) , ' =', max(0, X));
writeln('max(single(0), X) = ', maxov(single(0), X), ' =', max(single(0), X));
writeln('max(double(0), X) = ', maxov(double(0), X), ' =', max(double(0), X));
writeln('max(0, double(X)) = ', maxov(0, double(X)), ' =', max(0, double(X)));
end.
Outputs this:
X = 5.1354860533066997E+001
max(X, 0) = max(single, single) = 5.135486221E+01
max(X, single(0)) = max(double, double) = 5.1354860533066997E+001
max(X, double(0)) = max(double, double) = 5.1354860533066997E+001
max(double(X), 0) = max(single, single) = 5.135486221E+01
max(0, X) = max(single, single) = 5.135486221E+01
max(single(0), X) = max(double, double) = 5.1354860533066997E+001
max(double(0), X) = max(double, double) = 5.1354860533066997E+001
max(0, double(X)) = max(single, single) = 5.135486221E+01
Clearly showing that max(DoubleValue, IntegerValue)
chooses max(single, single)
overload.
Edited by Rika