关于数据库里的值是0.05,通过dw取出来是0.049999的尾差问题

来源:互联网 发布:latex for mac 编辑:程序博客网 时间:2024/05/16 16:08
如果数据库表里的字段属性是float,那么PB连接数据库表的时候,float会转成number
这时候对dw取数(dw.getitemdecimal或者dw.object.iprice[row]),
会得到有尾差的数

如:
数据库的表 test 里的字段 iprice 的属性是float,值0.05
dw.retrieve()
ld_price = dw.getitemdecimal(row,iprice)
则ld_price = 0.04999999

要解决这个问题,需要修改这个dw的editsource
把iprice字段的type属性从number改成decimal(6)

这样就能避免这种尾差。



注意:
1、今后在新增表的时候,需要考虑,避免直接使用float属性字段
2、在建立新的dw的时候,注意数据源里是否有类似 iprice 那样editsource里type属性为number的字段,需要将它们改成decimal(6)

阅读全文
0 0