From: Tom Lane <tgl@sss.pgh.pa.us>
To: Gallacher Neil <Neil.Gallacher@gstt.nhs.uk>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: ERROR: value out of range: underflow in numeric log calculation
Date: Tue, 21 Nov 2023 13:34:10 -0500
Message-ID: <1526793.1700591650@sss.pgh.pa.us> (raw)
In-Reply-To: <CWLP265MB5906D3545378C97AADA62BE3DEBBA@CWLP265MB5906.GBRP265.PROD.OUTLOOK.COM>
References: <CWLP265MB5906D3545378C97AADA62BE3DEBBA@CWLP265MB5906.GBRP265.PROD.OUTLOOK.COM>
Gallacher Neil <Neil.Gallacher@gstt.nhs.uk> writes:
> When executing log calculations (example below):
> SELECT 1.0 * exp(-1.0 *(ln(2) * (1695993520/86400.0)) / 0.04) AS result_test;
> The following error occurs.
> ERROR: value out of range: underflow
Yup.
> I can however understand that an individual might wish to know that the result of a calculation cannot be represented by the system due to its small value however I don't believe it should be the default behaviour.
You'd be in a minority on that opinion. In this case you could work
around it by asking for the calculation to be done in numeric rather
than float8:
regression=# SELECT 1.0 * exp(-1.0 *(ln(2::numeric) * (1695993520/86400.0)) / 0.04) AS result_test;
result_test
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
(1 row)
but I'm not sure how far that covers your real use-case.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, Neil.Gallacher@gstt.nhs.uk, pgsql-bugs@lists.postgresql.org
Subject: Re: ERROR: value out of range: underflow in numeric log calculation
In-Reply-To: <1526793.1700591650@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox