Re: Working with fixed-point calculations in C

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oskar Stenberg <oskar_stenberg(at)outlook(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Working with fixed-point calculations in C
Date: 2021-12-08 03:41:38
Message-ID: 3607050.1638934898@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oskar Stenberg <oskar_stenberg(at)outlook(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vikas Sharma 2021-12-08 10:25:20 Re: how to get value of parameter set in session for other user
Previous Message David G. Johnston 2021-12-08 02:14:37 Re: CTE Materialization