[DUG] Maths problem for the day

Karl Reynolds kreynolds at chocfishsoft.co.nz
Tue Jan 11 15:53:15 NZDT 2011


Max := Bias.Position * Trunc(Log10(Math.Max(10, High(Files) * 10 div 3)));

> That was my point, the original describes exactly what was intended. One
> liners generally don't and tend to introduce errors

The "etc" kind of throws a spanner in the works. But yes, the
following is slightly more readable:

var Magnitude: Integer;

Magnitude := High(Files) * 10 div 3;
if Magnitude < 10 then Magnitude := 10;
Max := Bias.Position * Trunc(Log10(Magnitude));

Cheers,
Karl


More information about the Delphi mailing list