Search Postgresql Archives

Re: Strange results when casting string to double

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

 



On Thu, Feb 17, 2022 at 09:41 AM Thomas Kellerer wrote:
Carsten Klein schrieb am 16.02.2022 um 14:27:
Ah, man versteht sich :)
I'm using several (now unsupported) PostgreSQL 9.3.24 servers on
different (ancient) Ubuntu 14.04 LTS machines. On only one of those
servers, I get strange/wrong results when converting a string into a
double value:

SELECT 1.56::double precision;

--> 1.55999999999999   (wrong!)

Although I do not find any differences in configuration, on all other servers the result looks like this (correct?):

SELECT 1.56::double precision;

--> 1.56               (correct!)


I wonder if extra_float_digits is different between those  systems
Maybe initialized by differently configured SQL clients.

As I've seen in the sources in file /src/backend/utils/adt/float.c, extra_float_digits is used when converting double precision values back to text only. The binary (BIT) representation if the double value's fraction (mantissa) tells me, that the actual double precision value is already wrong.

Also, extra_float_digits is constantly zero in my tests. I've only been using pgAdmin III for that and always ensured with

SELECT current_setting('extra_float_digits');

that it's zero.

Carsten






[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