Re: rounding problems

From: Justin <justin(at)emproshunts(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: rounding problems
Date: 2008-05-13 15:30:48
Message-ID: 4829B428.8000408@emproshunts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tomasz Ostrowski wrote:
> On 2008-05-12 20:49, Justin wrote:
>
>
>> We take (List Price * discount Percent) * Number of Pieces = net
>> price.
>>
>
> This is wrong. You should do in Excel:
> ( price * amount ) * discount
> As otherwise any small error in representation of price*discount would
> be multiplied by usually high amount.
>

Your saying in Excel, Multiplication is not Commutativity??? that
sends shudders down my back
> I'd do this way to get it right:
> round( round(price * amount, 2) * discount, 2)
> This way every sum should match. There could be errors, but in pennies,
> not dollars. These errors will be because Excel does not have a decimal
> type.
>
That makes sense you are keeping the precision the same through the
calculation
> It is a lost case to break Postgres so it will match Excel. Much easier
> would be to correct Excel spreadsheet. And this is a right thing to do.
>
> Regards
> Tometzky
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2008-05-13 15:31:58 Re: pg_standby / WAL archive-restore through system restarts
Previous Message Stephen Ince 2008-05-13 15:27:54 multicolumn index join