Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: rounding pr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 36 Topic 15511 of 16941
Post > Topic >>

Re: rounding problems

by justin@[EMAIL PROTECTED] (Justin) May 12, 2008 at 02:54 PM

Lincoln Yeoh wrote:
> At 01:48 AM 5/13/2008, Justin wrote:
>> I have very annoying problem that i would like to get a work around  
>> in place so the data entry people stop trying to kill me.
>>
>> Normally people give quotes out of the price book which was done in 
>> Excel like 15 years ago and just has been updated over the years.  
>> the problem is excel is rounding differently than postgres 8.3.1 (Yes 
>> i know Excel rounds incorrectly) which results in normally being 
>> pennies off but on large qty its usually under a few bucks on the 
>> postgresql side.
>> We internally don't  care but those annoying customers scream bloody 
>> murder if the quote don't agree to the penny on the invoice  Even 
>> when its to their benefit .
>>
>> Has anyone every got  Postgresql and Excel to agree on rounding.
>> I have checked excel up to Office XP and its still wrong.  (open 
>> office was looked out and the people  screamed really loudly NO )
>>
>> Another annoying thing is the calculators on everyones desk get it 
>> wrong to if the rounding is turned to 2 places.
>>
>> Although my TI-89, and TI-36X calculators agree perfectly with 
>> postgresql .
>
> Bad news, the Excel thing is probably doing math very wrong.
>
> Also, my guess is you're treating one penny as 0.01, which is also
wrong.
The fields are numeric(12,4)  and numeric(10,2) .  I'm in process of 
extending the precision out on the acounting side because its causing 
problems with inventory costing, as we have raw material priced in $50 
to $100 a pound but only consume .000235 lbs per part.  so we can 
getting some funky results. 

I did not layout the database.  The person who laid out the database 
knows even less math than i do, we have numeric fields (20,10) to (10,4) 
and everything in between.  it creates some funky results due to 
truncating and rounding in the different fields.  You have raw material 
priced as high as thing are today it starts adding up to some major 
issues.  Multiply that by thousands of transactions it just way wrong.

I learned long ago make sure every field in the database have the same 
precision and deal with the rounding at the UI side.  I learned this 
because of my work in low resistance measurements taken at the ppm scale.
>
> When you do financial calculations you should avoid floating point 
> where possible. Floating point is really tricky to get right. There 
> are scary books on it.

I know this and experienced it before.  Again someone did not know what 
they where doing and i got left picking up the pieces.  Not to say my 
first time through i did not make all kind of mistakes but i fixed my.

To add further murky the water for the users our last ERP packaged used 
round to next highest number which trashed cost accounting as it used 
more raw material than it should have.

>
> I'm no expert in financial calculations and floating point stuff, my 
> _guess_ is a good start is probably treating one penny as 1, instead 
> of 0.01. But better wait for the experts to chime in.
>
> That said, if you're going to insist on using the wrong numbers from 
> the Excel Invoice, can't you work some way of getting them into 
> Postgresql and stored "as is", rather than having Postgresql calculate 
> them differently ( I suspect you're using floating point in postgresql 
> and so it'll be wrong too, just maybe a bit less wrong than Excel ;) ).

No floating point is being used every variable is declared as numeric on 
the Postgresql side and in the C++  which is the UI side everything is 
double.
>
> Regards,
> Link.
>
>
>
>
>

-- 
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
 




 36 Posts in Topic:
rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 13:48:16 
Re: rounding problems
lyeoh@[EMAIL PROTECTED]   2008-05-13 02:07:09 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 14:54:47 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 15:08:11 
Re: rounding problems
craig@[EMAIL PROTECTED]   2008-05-13 04:29:06 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 17:02:30 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 17:09:57 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 17:23:15 
Re: rounding problems
craig@[EMAIL PROTECTED]   2008-05-13 05:50:16 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 18:37:02 
Re: rounding problems
aanderson@[EMAIL PROTECTE  2008-05-12 19:04:13 
Re: rounding problems
sam@[EMAIL PROTECTED] (S  2008-05-13 02:20:18 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 22:51:42 
Re: rounding problems
craig@[EMAIL PROTECTED]   2008-05-13 11:42:09 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-13 00:16:06 
Re: rounding problems
xof@[EMAIL PROTECTED] (C  2008-05-12 14:53:21 
Re: rounding problems
craig@[EMAIL PROTECTED]   2008-05-13 05:26:46 
Re: rounding problems
aanderson@[EMAIL PROTECTE  2008-05-12 14:18:57 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 14:49:48 
Re: rounding problems
tometzky@[EMAIL PROTECTED  2008-05-13 08:40:41 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-13 11:30:48 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-13 13:29:07 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-13 14:36:18 
Re: rounding problems
sam@[EMAIL PROTECTED] (S  2008-05-14 15:38:17 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-14 11:47:52 
Re: rounding problems
sam@[EMAIL PROTECTED] (S  2008-05-14 17:26:30 
Re: rounding problems
sam@[EMAIL PROTECTED] (S  2008-05-14 20:27:19 
Re: rounding problems
aanderson@[EMAIL PROTECTE  2008-05-14 16:02:32 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-14 16:08:54 
Re: rounding problems
aanderson@[EMAIL PROTECTE  2008-05-14 16:24:58 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-14 16:55:49 
Re: rounding problems
glene77is <glen.e77is@  2008-05-20 03:19:20 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-20 10:28:28 
Re: rounding problems
aanderson@[EMAIL PROTECTE  2008-05-12 15:56:30 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-13 13:01:11 
Re: rounding problems
doug@[EMAIL PROTECTED] (  2008-05-13 12:12:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 12:45:29 CDT 2008.