一个四舍五入函数 (转)[@more@]
一个四舍五入函数
http://www.tommstudio.com(2001年4月19日) 作者:booktian 推荐:booktian
下面是保岛国整数的四舍五入函数,如果要保岛国n位小数,只需简单修改。
function myround(x : extended) : extended;
begin
if (int(x)*10+5) > int(x*10) then
begin
result := floor(x);
end else
begin
result := ceil(x);
end;
end;
http://www.tommstudio.com(2001年4月19日) 作者:booktian 推荐:booktian
下面是保岛国整数的四舍五入函数,如果要保岛国n位小数,只需简单修改。
function myround(x : extended) : extended;
begin
if (int(x)*10+5) > int(x*10) then
begin
result := floor(x);
end else
begin
result := ceil(x);
end;
end;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-989004/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10752043/viewspace-989004/
四舍五入函数实现
3328

被折叠的 条评论
为什么被折叠?



