Delphi的四舍五入函数

来源:互联网 发布:淘宝为什么没有西瓜刀 编辑:程序博客网 时间:2024/05/17 03:31
function x_round(x: double): double;
var
  x10: double;
  xx: integer;
begin
  x10 := abs(x) * 100 + 0.5;
  xx := trunc(x10);
  result := xx / 100;
  if x<0 then
    result:=-result;
end;
原创粉丝点击