【发布时间】:2017-03-27 16:53:40
【问题描述】:
我有一个带有var Extended 参数的函数。如果我在调用函数时尝试使用 Double 类型参数,编译器会报错。但是,如果我将 Extended 值作为函数 Result 传回(并分配给 Double 变量),那么编译器会很高兴。
这是预期的吗?如果是这样,有什么方法可以欺骗编译器降低参数的精度以匹配参数?
function foo1(var e: extended): boolean;
begin
e := 0.0;
Result := true;
end;
function foo2(): extended;
begin
Result := 0.0;
end;
procedure CallFoo();
var
d: double;
begin
if foo1(d) then Exit; // compiler complains
d := foo2; // compiler happy
end;
【问题讨论】:
标签: delphi