Re: double and numeric conversion - Mailing list pgsql-hackers

From Theo Schlossnagle
Subject Re: double and numeric conversion
Date
Msg-id BF2CDE34-127D-4469-B663-7B02ACF7968A@omniti.com
Whole thread Raw
In response to Re: double and numeric conversion  (Yeb Havinga <yebhavinga@gmail.com>)
Responses Re: double and numeric conversion
List pgsql-hackers
I can't release all of it, but the functions to convert uint64_t, int64_t and double to numeric Datum are the meat and
Ican expose those... 

https://labs.omniti.com/pgsoltools/trunk/contrib/scratch/pg_type_to_numeric.c

As I mentioned, the dscale on the double_to_numeric is imperfect resulting in things like: 1.23 turning into 1.2300 in
thenumeric returned.  This are significantly faster (as expected) than the type -> string -> numeric conversions. 


On Mar 3, 2010, at 5:01 AM, Yeb Havinga wrote:

> 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
tointegrate and unit test. We make heavy use of the numeric data type, so I'm very interested! 
>
> regards
> Yeb Havinga
>
>

--
Theo Schlossnagle
http://omniti.com/is/theo-schlossnagle







pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [GENERAL] to_timestamp() and quarters
Next
From: Tom Lane
Date:
Subject: Re: USE_LIBXSLT in MSVC builds