首页 > 解决方案 > 小数之和只有16位吗

问题描述

create table t (mnt decimal(20,2));
insert into t values (111340534626262);
insert into t values (0.56);
select sum(mnt) from t;
select sum(mnt::decimal(20,2))::decimal(20,2) from t;

我不能超过 16 位数。任何的想法?

使用 IDS 12.10FC10。

标签: informix

解决方案


当我运行程序中显示的代码时sqlcmd,我得到输出:

111340534626262.56
111340534626262.56

当我运行 Informix 的 DB-Access 程序中显示的代码时,我得到以下输出(稍作改动):

           (sum) 

 111340534626263

1 row(s) retrieved.        

    (expression) 

 111340534626263

1 row(s) retrieved.

因此,问题可能出在 DB-Access 的显示机制上,而不是服务器本身。

如果您正在编写自己的代码,那么确保显示准确和完整是相对简单的。使用 DB-Access 不一定是最好的方法。


推荐阅读