DELPHI的trunc函数
2014-01-04 13:52
344 查看
delphi函数trim()与trunc()区别:一个对字符串操作一个对数字操作
procedure TForm1.FormCreate(Sender: TObject); var f : double; begin f := 1.50; showmessage(IntToStr(Trunc(f))); // 1 截取 showmessage(IntToStr(Round(f))); // 2 四舍五入 showmessage(IntToStr(Ceil(f))); // 2 向上取整 showmessage(IntToStr(floor(f))); // 1 向下取整 f := 1.40; showmessage(IntToStr(Trunc(f))); // 1 截取 showmessage(IntToStr(Round(f))); // 1 四舍五入 showmessage(IntToStr(Ceil(f))); // 2 向上取整 showmessage(IntToStr(floor(f))); // 1 向下取整 f := -1.50; showmessage(IntToStr(Trunc(f))); // -1 截取 showmessage(IntToStr(Round(f))); // -2 四舍五入 showmessage(IntToStr(Ceil(f))); // -1 向上取整 showmessage(IntToStr(floor(f))); // -2 向下取整 f := -1.40; showmessage(IntToStr(Trunc(f))); // -1 截取 showmessage(IntToStr(Round(f))); // -1 四舍五入 showmessage(IntToStr(Ceil(f))); // -1 向上取整 showmessage(IntToStr(floor(f))); // -2 向下取整 // showmessage(IntToStr(Integer(f))); //不能这样 Error // 截取就是你能看到的整数是多少就是多少 // 四舍五入, 这个不用多说了 // 向上取整, 比这个值大的 最小整数 // 向下取整, 比这个值小的 最大整数 end;
相关文章推荐
- Delphi 之遞增與遞減函數
- delphi xe4 ini文件不能读取的解决方法
- Delphi中如何释放内存(转)
- 一个Delphi7的BUG
- Windows Server 2008运行Delphi程序报xxxxx.bpl错误
- delphi里FormatFloat的用法
- Delphi url 编码及转码及特殊字符串替换--百度和腾讯用的就是这个
- DELPHI U盘插入拔出提示
- Delphi直接让QT进入指定房间
- 通过Delphi获得qq安装路径
- 怎样调试delphi写的服务程序-com对象及hook程序
- 纪念经典的 D7(Delphi 7编码转换程序)
- Delphi 变体类型(Variant)的介绍(流与变体类型的相互转换、变体类型常用的函数)
- delphi Inc函数和Dec函数的用法
- Delphi XE4中Or, In, CharInSet,哪个更快?
- Delphi 快捷键
- delphi 获取本机IP地址和MAC地址
- delphi中in的使用
- Delphi - 数组 详解
- delphi for xx in xx do 语法的使用示例