Quote:
|
Originally Posted by kristjangudni
I need someone to explain to me how the SUMfunction works. Sounds stupid and maybe it is but I have a problem with this function. The problem is like this:
My table has a REAL column have two values. They are 968.9 and 927.9. When I do a select with SUM (select sum(ps) form ...) then DB2 returns 1896.800048828125. How come it returns with all these decimal numbers. I expect only to get 1896.8 and nothing more. I know that SUM returns double and I do something like "select decimal(sum(ps),10,2)..."
|
The SUM function works exactly as it should with floating point numbers.
Floating point representation (that is, REAL or DOUBLE) of a number is inaccurate by definition. If you need more predictable results use DECIMAL.
You don't write software for a financial institution, do you? I should think about keeping my money under my mattress
:-)