How about adding rational fraction to Python?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Mon Feb 25 10:02:38 EST 2008


On Sun, 24 Feb 2008 23:41:53 -0800, Dennis Lee Bieber wrote:

> On 24 Feb 2008 23:04:14 -0800, Paul Rubin <http://phr.cx@NOSPAM.invalid>
> declaimed the following in comp.lang.python:
> 
> 
>> Usually you would round to the nearest penny before storing in the
>> database.
> 
> 	Tell that to the payroll processing at Lockheed...My paycheck
> tends to vary from week to week as the database apparently carries
> amount to at least 0.001 resolution, only rounding when distributing
> among various taxes for the paycheck itself. Tedious data entry in
> Quicken as I have to keep tweaking various tax entries by +/- a penny
> each week.


"Worst practice" in action *wink*

I predict they're using some funky in-house accounting software they've 
paid millions to a consultancy firm (SAP?) for over the decades, written 
by some guys who knows lots of Cobol but no accounting, and the internal 
data type is a float.

[snip]

> 	Oh... And M$ -- the currency type in VB is four decimal places.

Accounting standards do vary according to context: e.g. I see that 
offical Australian government reporting standards for banks is to report 
in millions of dollars rounded to one decimal place. Accountants can 
calculate things more or less any way they like, so long as they tell 
you. I found one really dodgy example:

"The MFS Water Fund ARSN 123 123 642 (‘the Fund’) is a registered managed 
investment scheme. ... MFS Aqua may calculate the Issue Price to the 
number of decimal places it determines."

Sounds like another place using native floats. But it's all above board, 
because they tell you they'll use an arbitrary number of decimal places, 
all the better to confuse the auditors my dear.


-- 
Steven



More information about the Python-list mailing list