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

From Oskar Stenberg
Subject Working with fixed-point calculations in C
Date
Msg-id HE1PR03MB2971DE2527ECE1E99D6C19A8F96E9@HE1PR03MB2971.eurprd03.prod.outlook.com
Whole thread Raw
Responses Re: Working with fixed-point calculations in C  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi!

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)

Anyway, I thought that it would be good to store the decimal numbers in the database as the datatype NUMBER, and then just use the C version of it when I need to work with it in the code. But when I look at the documentation for writing C functions, I can't find the C version of it? Is that something that just hasn't made it to the documentation, or is there a reason for it not being listed there?

Was hoping that I wouldn't need to reinvent the wheel here or include another library to handle this, as it increases the risk of creating bugs. But if I have to I'll do it.

You have to scroll down a little and you will find a table matching PostgreSQL:s datatypes with the datatypes in C

Best regards
Oskar

pgsql-general by date:

Previous
From: "Zwettler Markus (OIZ)"
Date:
Subject: error connecting to pgbouncer admin console
Next
From: Дмитрий Иванов
Date:
Subject: Re: CTE Materialization