Is there a MulDiv function for cross platform usage?

cross-platform, delphi, delphi-xe3

Solution

There is no `MulDiv` function for cross platform usage, there's just the one imported from Windows. So, you'll need to make such function for different platforms by yourself if you need it. For instance Lazarus uses for this the similar code:

function MathRound(AValue: Extended): Int64; inline;
begin
  if AValue >= 0 then
    Result := Trunc(AValue + 0.5)
  else
    Result := Trunc(AValue - 0.5);
end;

function MulDiv(nNumber, nNumerator, nDenominator: Integer): Integer;
begin
  if nDenominator = 0 then
    Result := -1
  else
    Result := MathRound(Int64(nNumber) * Int64(nNumerator) / nDenominator);
end;

Source `lcltype.pp` unit and issue `#0009934`.

Problem

Can anyone help me to find a unit, which defines the `MulDiv` function in Delphi XE3 for cross platform usage ? Its prototype is defined in Windows unit (as usually), what won't obviously work under OSX. Is there a `MulDiv` function for cross platform usage in Delphi XE3 ?

Original source