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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: How can I accurately infer the output of a SELECT statement FROM a table with floating-point data type?
Дата
Msg-id 3259196.1697688771@sss.pgh.pa.us
обсуждение исходный текст
Ответ на How can I accurately infer the output of a SELECT statement FROM a table with floating-point data type?  (毛毛 <krave@163.com>)
Ответы Re: How can I accurately infer the output of a SELECT statement FROM a table with floating-point data type?
Список pgsql-general
=?GBK?B?w6vDqw==?= <krave@163.com> writes:
> Do we have a rule by follow which one can accurately info the output of a SELECT statment FROM a table with
floating-pointdata type? 

The goal of our floating-point output functions is to produce
the shortest representation from which the stored value could
be recovered exactly.  It's not unusual for that to require
two or three decimal digits more than the nominal precision.
Keep in mind that the nominal precision, such as 6 digits for
float4, is a *lower bound* on the number of decimal digits
that will be stored accurately, whereas supporting exact
round-trip I/O requires an *upper bound* number of digits.

In short, no, there is not a trivial way to predict the
number of digits emitted.  If you have a problem with that,
maybe you should be using type numeric instead.

You can find more info by looking around for info about the
Ryū float output algorithm, eg here:

https://github.com/ulfjack/ryu

            regards, tom lane



В списке pgsql-general по дате отправления:

Предыдущее
От: 毛毛
Дата:
Сообщение: How can I accurately infer the output of a SELECT statement FROM a table with floating-point data type?
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: How can I accurately infer the output of a SELECT statement FROM a table with floating-point data type?