I'm working on an old school Delphi 5 application and I've noticed something about the Math.Floor
function.
I have an expression that I would like to evaluate the Floor of
But when I calculate the floor
I end up with a value that is clearly not correct, presumably due to integer overflow.
I thought of using the modulo operator as suggested here, but it looks like mod isn't applicable for these operands.
There's got to be a way ...
Thanks to David A's suggestion:
function CardinalFloor(X: Extended): Cardinal;
begin
Assert(X>=0);
Result := Cardinal(Trunc(X));
end;
is one possible work around