注意,DELPHI中的round()有问题的,如round(2.5)=2而不是3,可能是实数存储的问题,最好用
round(2.5+0.01)才能为3
round(2.5+0.01)才能为3
解决方案 »
- 这个情况处理数据看看大家有没有简单的处理办法
- low,high他们有什么作用?
- 跪求 ------Delphi中 100分奉送 解决马上给分!!!!!!!
- 如何在一个程序中激活另一个已经被最小化或失去焦点的窗口?
- 谁有可以控制图片大小的控件或代码,在線等待
- 用dbexpress组件连接数据库,怎样用代码设置SQLConnection?高手指点!
- 急!窗体中控件居中和大小改变的问题
- ■■[调查]您用Linux搞开发了吗?请大家帮忙UP!
- 谁能为小第说说网站提供的下载功能是怎么实现的吗?
- 数据库更新,好怪的现象哦!!!
- 找高手做Internet项目
- 当鼠标在richedit上移动的时候,我想知道鼠标下的字符是什么。
x: Float...
x := 3.1415926;
x := Trunc(x * 100 + .5) / 100; // 100保留2位,1000保留3位, etc...
var
r1, r2: double;begin
r1 := 234.451;
r2 := StrToFloat(formatFloat('.00', r1));
if r2 - r1 > 0 then r2 := r2 - 0.01;
showmessage(Floattostr(r2));
result := r2;//结果
end;想4舍5入
r2 := StrToFloat(formatFloat('.00', r1));
showmessage(Floattostr(r2));
result := r2;//结果
end;
var
r1, r2: double;begin
r1 := 234.451;
r2 := StrToFloat(formatFloat('.00', r1));
if r2 - r1 > 0 then r2 := r2 - 0.01;
showmessage(Floattostr(r2));
result := r2;//r2示结果
end;你不想4舍5入
var
r2: double;begin
r2 := StrToFloat(formatFloat('.00', r2));
showmessage(Floattostr(r2));
end;
刚才没传上去。
r2:=floattoint(r1*100)/100;
result=r2;