select round(product_qty * 100) - product_qty as test,
id, product_qty
from stock_move
where product_id=63
and state='done'
and id=45058;
test | id | product_qty 54.45 | 45058 | 0.55 (1 ligne)
select round(product_qty * 100) - (product_qty*100) as test,
id,
product_qty
from stock_move
where product_id=63
and state='done'
and id=45058;
test | id | product_qty -7.105427357601e-15 | 45058 | 0.55 (1 ligne)
有人可以给我解释一下这些结果?Postgres的双精度
你能告诉我们你想问什么吗? – 2011-08-31 09:45:37
双打计算受四舍五入误差影响,对此不能做太多的处理。很多文章在SO上处理这个主题,使用搜索 – fvu
伙计们,这是一个真正的问题(关于双精度不准确性),但已经通过fvu – Bohemian