谁能帮我找到一个在Delphi XE3中定义跨平台使用的MulDiv函数的单元?它的原型是以Windows为单位定义的(通常),这在OSX下显然是行不通的。
在Delphi XE3中有跨平台使用的MulDiv函数吗?
发布于 2013-02-25 19:33:46
没有跨平台使用的MulDiv函数,只有从Windows导入的函数。因此,如果你需要的话,你需要自己为不同的平台制作这样的函数。例如,Lazarus对此使用了类似的代码:
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;源lcltype.pp设备并发出#0009934。
https://stackoverflow.com/questions/15059778
复制相似问题