Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



=?GBK?B?w6vDqw==?= <krave@xxxxxxx> writes:
> Do we have a rule by follow which one can accurately info the output of a SELECT statment FROM a table with floating-point data 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






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux