Delphi 10.3 四舍五入函数
发布日期:2021-05-04 20:44:45 浏览次数:16 分类:技术文章

本文共 538 字,大约阅读时间需要 1 分钟。

//四舍五入函数function frmBS1.RoundIt(work: double): double;begin   //Round .5 up always.//Currency fields are stored with 4 decimals, so need to be rounded to 2 decimals when multiplying by exchange rates, etc.//example: frmBS1.RoundIt(amount * rate * 100)/100;    if work >0 then    begin      if Int(work + 0.5) > Int(work) then        result := Int(work) + 1      else        result := Int(work);    end  else    begin      if Int(work - 0.5) < Int(work) then        result := Int(work) - 1      else        result := Int(work);    end;end;

 

上一篇:Delphi 10.3 应用程序获取自身所在的目录文件夹名称
下一篇:Delphi 10.3 Rio的RadioGroup1控件如何设置 Items 的排列为横向横排水平显示

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2025年03月20日 01时51分15秒