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 1k2htt-0007aN-Ux for pgsql-docs@arkaria.postgresql.org; Mon, 03 Aug 2020 21:21:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k2hts-0005mi-JZ for pgsql-docs@arkaria.postgresql.org; Mon, 03 Aug 2020 21:21:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k2hts-0005ma-Dr for pgsql-docs@lists.postgresql.org; Mon, 03 Aug 2020 21:21:40 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k2htp-0007Oz-F9 for pgsql-docs@lists.postgresql.org; Mon, 03 Aug 2020 21:21:39 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1k2htn-0005T5-V9; Mon, 03 Aug 2020 17:21:35 -0400 Date: Mon, 3 Aug 2020 17:21:35 -0400 From: Bruce Momjian To: sprakash24oct@gmail.com, pgsql-docs@lists.postgresql.org Subject: Re: 7 decimal digits precision for real Message-ID: <20200803212135.GF17519@momjian.us> References: <159614830974.681.17017141356953934189@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <159614830974.681.17017141356953934189@wrigleys.postgresql.org> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Jul 30, 2020 at 10:31:49PM +0000, PG Doc comments form wrote: > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/12/datatype-numeric.html > Description: > > When I try to run > `insert into employees (r_id) values (3.919192199);` > where r_id is of type real, I see it stores as 3.9191923 and not 6. > Am I understanding anything wrong ? isn't the range specified is 6 digits > precision? Those extra digits are not guaraneteed to be precise, but usually are close to accurate, so we include, them. You can diable that with extra_float_digits = 0: SELECT '3.919192199'::real; float4 ----------- 3.9191923 SHOW extra_float_digits; extra_float_digits -------------------- 1 SET extra_float_digits = 0; SELECT '3.919192199'::real; float4 --------- 3.91919 -- Bruce Momjian https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee