写了一个函数,出错。帮忙看看。
icank 2003-01-08 01:20:10 function CutFloat(const Value: Extended; const Digits: Byte): Extended;
var
V1, LFactor: Extended;
V2: Int64;
begin
LFactor := IntPower(10, Digits);
V1 := Value * LFactor;
V2 := Trunc(V1);
V1 := V2 / LFactor;
Result := V1;
end;
用 CutFloat(100.51, 5) 调用,返回 100.51 正确。
但用 CutFloat(150.51, 5) 调用,返回的是 150.50999
V2 用的是 Int64 类型,15051000 并没有超出范围啊!怎么回事啊?
应该怎么样修改?