Re: Numeric patch to add special-case representations for < 8 bytes

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Patric Bechtel" <bechtel(at)ipcon(dot)de>, "pgsql-patches" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Numeric patch to add special-case representations for < 8 bytes
Date: 2007-03-02 12:02:16
Message-ID: 87fy8nsvjr.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> Patric Bechtel <bechtel(at)ipcon(dot)de> writes:
>> Tom Lane schrieb am 02.03.2007 14:38:
>>> Exact decimal fractions are no longer exact when converted to base 2.
>
>> I think multiplying with base 10 until it's a whole number, then saving
>> that exponent with it, that's how I understood it.
>
> That hardly seems likely to win in terms of calculation efficiency ---
> for example, adding two numbers will now likely require a multiplication
> in order to align the values for addition. Having to store the exponent
> doesn't sound that great for the original complaint of too much overhead
> for short numbers, either...

Adding two numbers with two different exponents would require multiplying to
set the exponents equal.

a) normally you're adding together numbers of the same type so normally you'll
have the same precision.

b) It's only going to hurt for very large numbers where handling base-10^n
numbers is *so* bad that the argument kind of breaks down.

c) I was picturing storing the exponent relative to the decimal place instead
of relative to the first digit as we do now. That means numbers like 1x10^6
might take more space but numbers like 123456 would take less since we
could define a missing exponent to represent an exponent of 0.

Incidentally -- doing what I just castigated Jonah for doing -- I looked
around and both libgmp and the java math.BigDecimal libraries use base-2
digits. The latter with base-10 exponents no less.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2007-03-02 14:59:57 Re: A little COPY speedup
Previous Message Simon Riggs 2007-03-02 10:25:18 Re: A little COPY speedup