Re: math error or rounding problem Money type - Mailing list pgsql-hackers

From Justin
Subject Re: math error or rounding problem Money type
Date
Msg-id 484B0DFE.2050101@emproshunts.com
Whole thread Raw
In response to Re: math error or rounding problem Money type  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: math error or rounding problem Money type  (Mark Kirkwood <markir@paradise.net.nz>)
List pgsql-hackers
<br /><br /> Tom Lane wrote: <blockquote cite="mid:24505.1212877614@sss.pgh.pa.us" type="cite"><pre wrap="">Justin <a
class="moz-txt-link-rfc2396E"href="mailto:justin@emproshunts.com"><justin@emproshunts.com></a> writes:
</pre><blockquotetype="cite"><pre wrap="">I believe i have found a math bug/rounding problem with Money type when 
 
its used with SUM()...  Postgresql 8.3.1   </pre></blockquote><pre wrap="">
You do know that money only stores two fractional digits?
        regards, tom lane </pre></blockquote> yes.  The question is why are the to sides not equal anymore <br /><br />
Takethis <br /><br /> Select <br />     '2',<br />     round(sum( beginBalance ),6) as beginbalance, <br />    
round(sum(negative ),6) as debit, <br />     round(sum( positive ),6) as credit, <br />     round(sum( difference ),6)
asdifference, <br />     round(sum( endbalance),6) as endbalance <br />  from trailbalance <br />  union <br />  Select
<br/>     '1',<br />     sum( round(beginBalance,6)) as beginbalance, <br />     sum( round(negative,6)) as debit, <br
/>    sum( round(positive,6)) as credit, <br />     sum( round(difference,6)) as difference, <br />     sum(
round(endbalance,6))as endbalance <br />  from trailbalance <br /><br /> "1"  -0.000006   -11250546.743752   
11250546.743752  0.000000   -0.000007<br /> "2"   0.000000    -11250546.743752   11250546.743752   0.000000   
0.000000<br/><br /> At the very least this show a clear warning when rounding do it after all the sum function is
callednot before.  <br /><br /> 

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: math error or rounding problem Money type
Next
From: Mark Kirkwood
Date:
Subject: Re: math error or rounding problem Money type