Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1munpv-0001kh-T0 for pgsql-general@arkaria.postgresql.org; Wed, 08 Dec 2021 03:41:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1munpu-0007Bc-QD for pgsql-general@arkaria.postgresql.org; Wed, 08 Dec 2021 03:41:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1munpu-00079i-FL for pgsql-general@lists.postgresql.org; Wed, 08 Dec 2021 03:41:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1munpr-0000CU-M3 for pgsql-general@lists.postgresql.org; Wed, 08 Dec 2021 03:41:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1B83fc1g3607051; Tue, 7 Dec 2021 22:41:38 -0500 From: Tom Lane To: Oskar Stenberg cc: "pgsql-general@lists.postgresql.org" Subject: Re: Working with fixed-point calculations in C In-reply-to: References: Comments: In-reply-to Oskar Stenberg message dated "Tue, 07 Dec 2021 23:39:41 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3607049.1638934898.1@sss.pgh.pa.us> Date: Tue, 07 Dec 2021 22:41:38 -0500 Message-ID: <3607050.1638934898@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Oskar Stenberg 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