Re: Numeric patch to add special-case representations for < 8 bytes - Mailing list pgsql-patches

From Gregory Stark
Subject Re: Numeric patch to add special-case representations for < 8 bytes
Date
Msg-id 87fy8nsvjr.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: Numeric patch to add special-case representations for < 8 bytes  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
"Tom Lane" <tgl@sss.pgh.pa.us> writes:

> Patric Bechtel <bechtel@ipcon.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

pgsql-patches by date:

Previous
From: "Simon Riggs"
Date:
Subject: Re: A little COPY speedup
Next
From: Tom Lane
Date:
Subject: Re: A little COPY speedup