On Feb 22, 2018, at 9:31 PM, Michael Paquier <mich...@paquier.xyz> wrote:


That function returns an object of datatype “Numeric” which still requires some 
(not immediately obvious) conversation to a double (or whatever primitive C 

> When working on implementing your own data
> types or when hacking out functions which manipulate arguments of an
> existing datatype, looking at the input and output functions help a
> lot.  In your case, numeric_in and numeric_out in
> src/backend/utils/adt/numeric.c is full of hints.

I spent an hour diving into the code out of curiosity. I found useful functions 
like this:

double numeric_to_double_no_overflow(Numeric n)

They’re available from the PostgreSQL main source code, but not exposed in the 
public headers. (Maybe I was missing something.) There was enough there where I 
could see a way to copy/paste or otherwise link to those methods, but as Tom 
pointed out, implicit coercion handles what I need so I’ll stick with that.


Reply via email to