关于Math.Floor的问题
procedure TForm1.btn1Click(Sender: TObject);
var
WLLatitudeFZ : double;
WLLatitudeI, WLLatitudeF : Integer;
begin
WLLatitudeFZ := 10.111;
WLLatitudeFZ := StrToFloat(Format('%.2f', [WLLatitudeFZ]));
WLLatitudeI:= Floor(WLLatitudeFZ);
WLLatitudeF:= Floor(Frac(WLLatitudeFZ) * 100);
ShowMessage(IntToStr(WLLatitudeF) + ',' + IntToStr(Floor(Frac(10.11)*100)));
end;
我预期结果是:11,11,因为WLLatitudeFZ=10.11
但是在Delphi7中的结果是:10,11,为什么?
WLLatitudeFZ := StrToFloat(Format('%.2f', [WLLatitudeFZ]));的本意在于只保持小数后两位,可是如果去掉这句话,结果就是11,11了,这又是为什么?
相关推荐
Java Math.round(),Math.ceil(),Math.floor()的区别详解
主要介绍了Java Math.round(),Math.ceil(),Math.floor()的区别详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
Math取整方法区别[可运行源码]
本文详细介绍了Math.round()、Math.ceil()和Math.floor()三种取整方法的区别。Math.round()实现四舍五入,但当小数点第一位为5时,正负数处理方式不同:正数进位,负数直接舍去。Math.ceil()为向上取整,小数部分直接舍去并向整数部分进1。Math.floor()为向下取整,直接舍去小数部分。文章还通过具体示例展示了不同方法的计算结果,并特别指出Math.floor()可能存在的精度问题,提醒读者谨慎使用。
JavaScript Math.floor方法(对数值向下取整)
主要介绍了Math.floor 方法用于对数值向下取整,即得到小于或等于该数值的最大整数,需要的朋友可以参考下
JavaScript中使用Math.floor()方法对数字取整
主要介绍了JavaScript中使用Math.floor()方法对数字取整,是JS入门学习中的基础知识,需要的朋友可以参考下
JavaScipt中的Math.ceil() 、Math.floor() 、Math.round() 三个函数的理解
首先还是看看[removed] The Definitive Guide, 4th Edition中对三个函数的定义。 Math.ceil(): round a number up Arguments: Any numeric value or expression Returns: The closest integer greater than or equal to x. ———————————————————————————————– Math.floor(): round a number down Arguments: Any numeric value or expressi


语言基础/算法/系统设计
