RE: Working with fixed-point calculations in C - Mailing list pgsql-general

From Oskar Stenberg
Subject RE: Working with fixed-point calculations in C
Date
Msg-id HE1PR03MB29713B33B0C6FE6ECCB80D82F96F9@HE1PR03MB2971.eurprd03.prod.outlook.com
Whole thread Raw
In response to Re: Working with fixed-point calculations in C  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi, thanks for your answer!  


Yeah, that's correct, I meant NUMERIC and not NUMBER. It was late and I must have accidentally mixed up the names... But thanks for pointing that out! :) But just to clarify, the data type NUMERIC is a fixed point number and not a floating point number?


Alright, so the documentation is just out of date, that's actually what I was hoping for! And while it would be great if it could be updated! Do you in the meantime happen to know where the datatype NUMERIC is defined in the code? And is it the same name in C as in postgres? Or is it something else?


Best Regards 

Oskar


-------- Originalmeddelande --------
Från: Tom Lane <tgl@sss.pgh.pa.us>
Datum: 2021-12-08 04:41 (GMT+01:00)
Till: Oskar Stenberg <oskar_stenberg@outlook.com>
Kopia: pgsql-general@lists.postgresql.org
Ämne: Re: Working with fixed-point calculations in C

Oskar Stenberg <oskar_stenberg@outlook.com> writes:
> I need to make some fixed-point calculations inside the C code that I'm
> developing as an extension to PostgreSQL. I was reading a bit, and if I
> understood the datatype NUMBER correctly, it seems to be just what I'm
> looking for, a fixed-point datatype. (I couldn't actually find any
> thing in the documentation that specifically mentions that it is a
> fixed point datatype. But it seems to work the same. So I might be
> wrong here and if so please tell me)

I think what you are looking for is NUMERIC.  (The type name NUMBER
is an Oracle-ism, I believe.  I'm not sure how closely that corresponds
to our NUMERIC.)

> Link to the documentation:
> https://www.postgresql.org/docs/current/xfunc-c.html#XFUNC-C-TYPE-TABLE

Hmm, that table seems a bit incomplete/out of date.  While it's
not really meant to cover every type, surely it should mention
bigint, numeric, and timestamptz ...

                        regards, tom lane

pgsql-general by date:

Previous
From: "Zwettler Markus (OIZ)"
Date:
Subject: AW: error connecting to pgbouncer admin console
Next
From: Shaozhong SHI
Date:
Subject: Re: How to allow null as an option when using regexp_matches?