Re: How can I accurately infer the output of a SELECT statement FROM a table with floating-point data type?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: 毛毛 <krave(at)163(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How can I accurately infer the output of a SELECT statement FROM a table with floating-point data type?
Date: 2023-10-19 04:14:47
Message-ID: CAKFQuwb7Dbsm-hDmJzCJ+ApipD7p-wqRunY5yqVCEq3AjYsxpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday, October 18, 2023, 毛毛 <krave(at)163(dot)com> wrote:
>
>
> I consulted the following doc and found that the range of real type is 6
> decimal digits precision.
> https://www.postgresql.org/docs/current/datatype-numeric.
> html#DATATYPE-NUMERIC
>

You also need to consult:

https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT

But in short, no, the result is input specific and you the user are not
expected to know or care about such details. The docs say you will get
between 6 and 9 digits depending on the value, under default settings. The
table gives the minimum as clarified in the prose. There is room in the
table to include more detail and it probably should.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sebastien Flaesch 2023-10-19 08:36:50 Build fails on RHEL 8.8 about libxml2 version
Previous Message Tom Lane 2023-10-19 04:12:51 Re: How can I accurately infer the output of a SELECT statement FROM a table with floating-point data type?