I'm proud to announce that the PEP for Decimal Data Type is now published
under the python.org structure: http://www.python.org/peps/pep-0327.html
This wouldn't has been possible without the help from Alex Martelli, Aahz,
Tim Peters, David Goodger and c.l.p itself.
After the pre-PEP roundups the features are almost established. There is not
agreement yet on how to create a Decimal from a float, in both explicit and
implicit constructions.
I depend on settle that to finish the test cases and actually start to work
on the code.
I'll apreciate any feedback. Thank you all in advance.
.. Facundo 5 1381
In article <40***************@easystreet.com>, <ac*****@easystreet.com> wrote: If python adds decimal data, it probably ought to be consistent with C and C++. Otherwise, the C and C++ guys will have a dreadful time writing emulation code to run on computers built to support python.
Read the PEP; Python's proposed decimal type is based on the existing
decimal standard. If C/C++ *don't* follow the standard, that's their
problem. BTW, Java uses the standard.
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/
"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code --
not in reams of trivial code that bores the reader to death." --GvR
In article <6l********************************@4ax.com>,
Stephen Horne <st***@ninereeds.fsnet.co.uk> wrote: On Fri, 30 Jan 2004 09:49:05 -0300, "Batista, Facundo" <FB******@uniFON.com.ar> wrote: I'll apreciate any feedback. Thank you all in advance.
My concern is that many people will use a decimal type just because it is there, without any consideration of whether they actually need it.
95% of the time or more, all you need to do to represent money is to use an integer and select appropriate units (pence rather than pounds, cents rather than dollars, etc) so that the decimal point is just a presentation issue when the value is printed/displayed but is never needed in the internal representation.
The problem lies precisely in that representation. For starters, a
binary integer is O(n^2) for conversion to decimal printing. Then
there's the question about multi-currency conversions, or interest
rates, or ....
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/
"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code --
not in reams of trivial code that bores the reader to death." --GvR
On 5 Feb 2004 09:16:51 -0500, aa**@pythoncraft.com (Aahz) wrote: In article <6l********************************@4ax.com>, Stephen Horne <st***@ninereeds.fsnet.co.uk> wrote:On Fri, 30 Jan 2004 09:49:05 -0300, "Batista, Facundo" <FB******@uniFON.com.ar> wrote: I'll apreciate any feedback. Thank you all in advance. My concern is that many people will use a decimal type just because it is there, without any consideration of whether they actually need it.
95% of the time or more, all you need to do to represent money is to use an integer and select appropriate units (pence rather than pounds, cents rather than dollars, etc) so that the decimal point is just a presentation issue when the value is printed/displayed but is never needed in the internal representation.
The problem lies precisely in that representation. For starters, a binary integer is O(n^2) for conversion to decimal printing.
In practice, there is an upper limit to the size of number that occurs
in any financial use, and of course we are not talking about tens of
digits let alone hundreds, meaning that the conversion is most
sensibly treated as O(1) for each number converted.
Anyway, speeding up the presentation of results makes little sense if
you slow down all the arithmetic operations to do it.
Then there's the question about multi-currency conversions, or interest rates, or ....
Admittedly needing better than penny precision, but still fixed
precision (ie suiting an integer representation with an implicit scale
factor) and the results are rounded.
I work with a company that writes accounting software. We don't need
to worry about currency conversions, but we do need to worry about
interest and other cases where fractional pennies seem to be implied
(rates for taxes, allowances etc) and basically the fractional pennies
are never really an issue - you do have to be careful with the
rounding rules, but that applies whatever representation you use.
--
Steve Horne
steve at ninereeds dot fsnet dot co dot uk
On 5 Feb 2004 09:16:51 -0500, aa**@pythoncraft.com (Aahz) wrote: In article <6l********************************@4ax.com>, Stephen Horne <st***@ninereeds.fsnet.co.uk> wrote:On Fri, 30 Jan 2004 09:49:05 -0300, "Batista, Facundo" <FB******@uniFON.com.ar> wrote: I'll apreciate any feedback. Thank you all in advance.
My concern is that many people will use a decimal type just because it is there, without any consideration of whether they actually need it.
95% of the time or more, all you need to do to represent money is to use an integer and select appropriate units (pence rather than pounds, cents rather than dollars, etc) so that the decimal point is just a presentation issue when the value is printed/displayed but is never needed in the internal representation.
The problem lies precisely in that representation. For starters, a binary integer is O(n^2) for conversion to decimal printing. Then
Please clarify. What is your "n" in that?
Regards,
Bengt Richter
> On 5 Feb 2004 09:16:51 -0500, aa**@pythoncraft.com (Aahz) wrote: The problem lies precisely in that representation. For starters, a binary integer is O(n^2) for conversion to decimal printing. Then
On Fri, Feb 06, 2004 at 06:56:03PM +0000, Bengt Richter wrote: Please clarify. What is your "n" in that?
"n" is the number of digits in the number, in this case.
A standard way to convert to base 10 looks like this:
def base10(i):
digits = []
while i:
i, b = divmod(i, 10)
digits.append(b)
digits.reverse()
return digits
Each divmod() takes from O(n) down to O(1) (O(log i) for each successive
value of i), and the loop runs n times (i is shortened by one digit each
time). This is a typical n^2 algorithm, much like bubble sort where the
outer loop runs n times and an inner loop runs 1-to-n times.
Jeff This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Batista, Facundo |
last post by:
Here I send it.
Suggestions and all kinds of recomendations are more than welcomed.
If it all goes ok, it'll be a PEP when I finish writing/modifying the code.
Thank you.
.. Facundo
|
by: Batista, Facundo |
last post by:
People:
I'll post a reviewed version of the PEP.
The only differences with the previous one will be the treatmen to float in
both explicit and implicit construction:
------------
In...
|
by: Blake T. Garretson |
last post by:
I'm having some issues with decimal.Decimal objects playing nice with
custom data types. I have my own matrix and rational classes which
implement __add__ and __radd__. They know what to do with...
|
by: John Bentley |
last post by:
John Bentley:
INTRO
The phrase "decimal number" within a programming context is ambiguous. It could
refer to the decimal datatype or the related but separate concept of a generic
decimal number....
|
by: Kevin Chambers |
last post by:
Hi there--
I'm having a heck of a time trying to create a field of data type decimal.
It seems like, according to the docs, the following two statements should
work just fine:
ALTER TABLE...
|
by: Ray |
last post by:
I have a table with some audit date and time columns. Problem is the
developer who stored the data left them as DECIMAL type instead of DATE
and TIME. Is there a way I can convert the DECIMAL type...
|
by: Lennart Benschop |
last post by:
Python has had the Decimal data type for some time now. The Decimal data
type is ideal for financial calculations. Using this data type would be
more intuitive to computer novices than float as its...
|
by: =?Utf-8?B?UGFvbG8=?= |
last post by:
I have a table column of SQL smallmoney type which I am updating via a form
input field defined as decimal.
If I enter, say, 51.09 via the decimal input field (representing $51.09),
this is...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |