[DB-SIG] Fixed point numbers (Result from DCOracle2 different from sqlplus)

M.-A. Lemburg mal@lemburg.com
Fri, 16 Nov 2001 10:46:12 +0100

paul@boddie.net wrote:
> <magnus@thinkware.se> wrote:
> >
> >It could actually be practical with a fixed point decimal data
> >type or standard class in Python. These kinds of values are common
> >in relational databases and for instance in administrative systems.
> >I think COBOL has such a data type. Unfortunately, this does not
> >exist in Python or in the DB-API standard.
> I wrote a simple implementation of a fixed point class for my XMLForms project;
> see http://www.paul.boddie.net for details. The class is called ScaledDecimal
> and is described in some detail in the documentation, which can be found here:
>   http://www.paul.boddie.net/Python/XMLForms/applications.html
>   (See the "Element Type Mappings" table and the text below it.)
> It isn't exactly sophisticated, but it does a lot more than the implementation
> that was floating around as part of one of the numeric PEPs.

How strong is the need for a fixed point data type ? 

I'm asking because I originally started the mxNumber project to
eventually come up with an implementation for rational numbers
or fixed point numbers. The rational number is there (it basically
wraps the GNU MP rational data type and thus is reasonably
fast), the fixed point number type is still missing -- mostly
because I'm not sure how to handle rounding/truncation "right"
(in some sense of the word "right").

Does anyone have pointers as to which logic is the most 
common ?

Note that a fixed point type wouldn't be hard to do with
Python's long implementation: you'd just have to keep an 
additional integer around which then defines the location
of the decimal point.

Marc-Andre Lemburg
CEO eGenix.com Software GmbH
Consulting & Company:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/