QrMain.FieldByName('率').AsVariant:=(QrMain.FieldByName('实查数').AsInteger/QrMain.FieldByName('应查数').AsInteger);要求保留两为小数,
用什么函数,
怎么解决怎样定义变量
用什么函数,
怎么解决怎样定义变量
解决方案 »
- 系统服务调用exe文件,文件无法自动关闭?
- 北京公司急招兼职DELPHI 7,Web Service程序开发高手
- 请教高手,ClientToScreen和MapWindowPoint函数的区别吗?
- 100分问题.请问我的UDP为什么不行呢? 请各位指教。
- 打印问题,请高手一定帮我忙!!!!
- 小问题,delphi中如何取得Messagebox的返回键,像C#中的DialogResult
- 请教一个关于cursor的问题
- 请教:如何才能有效地比较两条记录是否完全相同?
- 三层中,客户端如何接收服务器调用存储过程后存储过程的返回值
- 请大家帮忙看看怎样改进我这个程序。
- 请问,如何才能使自己的EXE文件在进程中只运行一个?
- 请教 TcompressStream如何使用
参数说明:
InReal:取整浮点数
Len:小数位数
RoundOrTrunc:0:是四舍五入;1:截断,2: 有小数时向上取整
function RoundReal(InReal: real; Len: integer; RoundOrTrunc: integer=0): real;
var
I, numb: integer;
str: string;
begin
try
numb := 1;
for i := 0 to len - 1 do
numb := numb * 10;
if RoundOrTrunc = 0 then //四舍五入
result := Round(InReal * numb) / numb
else
if RoundOrTrunc = 1 then //截断
begin
Str := FloatToStr(InReal * numb);
if pos('.', Str) = 0 then
Result := InReal
else
begin
Str := Copy(str, 0, pos('.', Str) - 1);
result := StrToFloat(Str) / numb;
end;
end
else //2: 有小数时向上取整,返回一个整数。
result := Ceil(InReal);
except
ShowMessage('浮点型数据转换错误!');
end;
end;