| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> | 
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org | 
| Cc: | ivbel(at)ispras(dot)ru | 
| Subject: | BUG #16357: Incorrect rounding for negative arguments in to_timestamp() | 
| Date: | 2020-04-11 06:01:49 | 
| Message-ID: | 16357-4ed50b3eb9a1a065@postgresql.org | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-bugs | 
The following bug has been logged on the website:
Bug reference:      16357
Logged by:          Ivan Beloborodov
Email address:      ivbel(at)ispras(dot)ru
PostgreSQL version: 9.6.17
Operating system:   Linux 5.0.0, Ubuntu 18.04.1
Description:        
to_timestamp() returns incorrect results for some negative arguments:
set extra_float_digits to 1;
SET
select extract(epoch from timestamp '1920-10-24 12:11:13.975227');
     date_part      
--------------------
 -1552218526.024773
(1 row)
select to_timestamp(-1552218526.024773) at time zone 'UTC';
          timezone          
----------------------------
 1920-10-24 12:11:13.975228
(1 row)
Whereas for positive arguments of the same magnitude everything's ok:
select extract(epoch from timestamp '2019-03-10 11:48:46.024773');
     date_part     
-------------------
 1552218526.024773
(1 row)
select to_timestamp(1552218526.024773) at time zone 'UTC';
          timezone          
----------------------------
 2019-03-10 11:48:46.024773
(1 row)
The problem is not with extra_float_digits:
set extra_float_digits to 0;
SET
select to_timestamp(-1552218526.024773) at time zone 'UTC' = timestamp
'1920-10-24 12:11:13.975227';
 ?column? 
----------
 f
(1 row)
And, as far as I understand, not with insufficient precision of float8, here
is an example with the same behaviour with 15 significant digits:
select extract(epoch from timestamp '1853-08-15 10:04:15.35064');
     date_part     
-------------------
 -3672568544.64936
(1 row)
select to_timestamp(-3672568544.64936) at time zone 'UTC';
          timezone          
----------------------------
 1853-08-15 10:04:15.350639
(1 row)
select extract(epoch from timestamp '2086-05-18 13:55:44.64936');
    date_part     
------------------
 3672568544.64936
(1 row)
select to_timestamp(3672568544.64936) at time zone 'UTC';
         timezone          
---------------------------
 2086-05-18 13:55:44.64936
(1 row)
Tested this behaviour on PostgreSQL 9.6.17, Linux 5.0.0, Ubuntu 18.04.1 and
PostgreSQL 10.1, Linux 4.4.0, Ubuntu 14.04.1
| From | Date | Subject | |
|---|---|---|---|
| Next Message | wenjing | 2020-04-11 14:54:38 | Re: [bug] Wrong bool value parameter | 
| Previous Message | Sandeep Thakkar | 2020-04-11 05:11:58 | Re: BUG #16341: Installation with EnterpriseDB Community installer in NT AUTHORITY\SYSTEM context not possible |