Re: double and numeric conversion

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Yeb Havinga <yebhavinga(at)gmail(dot)com>
Cc: Theo Schlossnagle <jesus(at)omniti(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: double and numeric conversion
Date: 2010-03-03 11:02:54
Message-ID: 162867791003030302j3f14d29bx1b0d65c54ba26561@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2010/3/3 Yeb Havinga <yebhavinga(at)gmail(dot)com>:
> Pavel Stehule wrote:
>>
>> 2010/3/3 Yeb Havinga <yebhavinga(at)gmail(dot)com>:
>>
>>>
>>> Theo Schlossnagle wrote:
>>>
>>>>
>>>> I didn't look deeply at the postgres internals to see if there was a way
>>>> to do double -> numeric and integer-types -> numeric without
>>>> intermediary
>>>> string format.  If that sort of thing is easy to leverage, I'd be happy
>>>> to
>>>> share the code.
>>>>
>>>>
>>>
>>> I think your code could be valuable for postgres on the fact alone that
>>> it
>>> is almost twice as fast, and probably easy to integrate and unit test. We
>>> make heavy use of the numeric data type, so I'm very interested!
>>>
>>
>> I did some test and numeric->double is about 5% faster than
>> numeric->string->double (on my PC)
>>
>
> numeric_to_double_no_overflow() also uses string as intermediate format.
>
> Theo's conversions are the converse, from double to numeric, and do not use
> string as intermediate format (if I understand it correct). (where
> float8_numeric
> http://doxygen.postgresql.org/backend_2utils_2adt_2numeric_8c.html#2de7f65c8de4b65dad441e77ea1bf402
> does)
>

aha - it is reason why time similar

Pavel

> regards
> Yeb Havinga
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2010-03-03 12:18:37 Re: USE_LIBXSLT in MSVC builds
Previous Message Yeb Havinga 2010-03-03 10:57:14 Re: double and numeric conversion