在ado中(jet 4.0)怎么会是5舍6入?round(5.55,1)竟然等于5.5!怎么办?

解决方案 »

  1.   

    caption:=floattostr(round(5.55 * 10) / 10);
      

  2.   

    不行啊,我用ADO中的jet 4.0来连接数据库,round我是在sql计算中使用,像update a,b set a.je=round(b.bl*a.sl,1) where a.id =b.id这样的sql,不能使用delphi自带的round.
      

  3.   

    呵呵,自己编函数呀
    (case b.bl*a.sl*10-floor(b.bl*a.sl*10)>=0.5 then (floor(b.bl*a.sl*10)+1)/10.0
     else (floor(b.bl*a.sl*10)+1)/10.0 end
    大概这样吧
      

  4.   

    可以验证:formatfloat('0.0',5.55) ='5.6';
    d:=5.55;
    d:=strtofloat(formatfloat('0.0',d));
      

  5.   

    不用费尽了,外国人的四舍五入与咱中国人的不同,人家“银行家算法”
    试试round(5.65,1)=?你就明白了
    它的算法如下:
    当要进位的上一位为偶数时5进位
    当要进位的上一位为奇数时5不进位,
    看来比较公平
    如果有兴趣可以自己做个函数,实现中国人的四舍五入。
    我的程序只为收款考虑,多收1分没事,少收1分不行,所以我用round(5.55+0.01,1)
      

  6.   

    你用的是什么数据库系统?
    access,sql server,oracle还是其他?
    access,sql server中是round
    ROUND
    返回数字表达式并四舍五入为指定的长度或精度。语法
    ROUND ( numeric_expression , length [ , function ] ) 参数
    numeric_expression精确数字或近似数字数据类型类别的表达式(bit 数据类型除外)。length是 numeric_expression 将要四舍五入的精度。length 必须是 tinyint、smallint 或int。当 length 为正数时,numeric_expression 四舍五入为 length 所指定的小数位数。当 length 为负数时,numeric_expression 则按 length 所指定的在小数点的左边四舍五入。function是要执行的操作类型。function 必须是 tinyint、smallint 或 int。如果省略 function 或 function 的值为 0(默认),numeric_expression 将四舍五入。当指定 0 以外的值时,将截断 numeric_expression。返回类型
    返回与 numeric_expression 相同的类型。注释
    ROUND 始终返回一个值。如果 length 是负数且大于小数点前的数字个数,ROUND 将返回 0。
      

  7.   

    我用的是ado+Jet 4.0+foxbase,