Incorrect rounding of double values at max precision

From: Gilleain Torrance <Gilleain(dot)Torrance(at)alfasystems(dot)com>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Incorrect rounding of double values at max precision
Date: 2019-10-21 11:29:04
Message-ID: DB3D1D143DDA534BBB39DE713E92343701CBA89718@GBEDBP01.chp.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

When storing a double in Postgres, it looks like under specific circumstances it can get rounded incorrectly:

select round(cast(float8 '42258656681.38498' as numeric), 2), round(numeric '42258656681.38498', 2);

which returns either 42258656681.38 or 42258656681.39 depending on whether it is float8 or not.

Thanks,

Gilleain

Gilleain Torrance
Consultant

Alfa
________________________________
e: Gilleain(dot)Torrance(at)alfasystems(dot)com | w: alfasystems.com<https://www.alfasystems.com>
t: +44 (0)20 7920 2855 | Moor Place, 1 Fore Street Avenue, London, EC2Y 9DT,
________________________________

The contents of this communication are not intended to be binding or constitute any form of offer or acceptance or give rise to any legal obligations on behalf of the sender or Alfa. The views or opinions expressed represent those of the author and not necessarily those of Alfa. This email and any attachments are strictly confidential and are intended solely for use by the individual or entity to whom it is addressed. If you are not the addressee (or responsible for delivery of the message to the addressee) you may not copy, forward, disclose or use any part of the message or its attachments. At present the integrity of email across the internet cannot be guaranteed and messages sent via this medium are potentially at risk. All liability is excluded to the extent permitted by law for any claims arising as a result of the use of this medium to transmit information by or to Alfa or its affiliates.

Alfa Financial Software Ltd
Reg. in England No: 0248 2325

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-10-21 14:20:53 Re: Re: Re: BUG #16068: Collate of 'Norwegian Bokmål' is problematic
Previous Message Bruno DUPUIS 2019-10-21 10:22:40 PGDG strech : postgresql-11-postgis-2.5 won't install beacause of missing dependency