Re: [HACKERS] numeric data type on 6.5 - Mailing list pgsql-hackers

From jwieck@debis.com (Jan Wieck)
Subject Re: [HACKERS] numeric data type on 6.5
Date
Msg-id m10ctKO-000EBPC@orion.SAPserv.Hamburg.dsh.de
Whole thread Raw
In response to Re: [HACKERS] numeric data type on 6.5  (Thomas Lockhart <lockhart@alumni.caltech.edu>)
List pgsql-hackers
Thomas Lockhart wrote:

> The float8_numeric() code already had checked for NULL and NaN, so I
> think this does not lose functionality. What do you think Jan? Should
> I make the change? Or is there another way??

    Think it's O.K. - commit the changes.

    The  other way would be to enhance the NUMERIC input function
    to read exponential notation. But  I  wouldn't  do  this  now
    because  I've planned to someday implement NUMERIC again from
    scratch.

    The current implementation has a packed  storage  format  and
    the  arithmetic  operations  are  based on a character format
    (each digit is stored in one byte).  After thinking about  it
    I  discovered,  that  storing  the  value internally in short
    int's (16 bit) and base 10000 would have some advantages.

    1.  No need to pack/unpack storage format for computations.

    2.  One arithmetic operation in  the  innermost  loops  (only
        add/subtract  are really implemented) mucks with 4 digits
        at a time.

    The disadvantages are small. Base 10000 to base 10  (decimal)
    conversion  is easily to parse/print. Only rounding functions
    will be a little tricky.  I think  the  speedup  gained  from
    adding/subtracting  4 digits per loop iteration will be worth
    the efford.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#======================================== jwieck@debis.com (Jan Wieck) #

pgsql-hackers by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: [HACKERS] numeric data type on 6.5
Next
From: jwieck@debis.com (Jan Wieck)
Date:
Subject: Re: [HACKERS] v6.5 Release Date ...