ERROR: value out of range: underflow in numeric log calculation

From: Gallacher Neil <Neil(dot)Gallacher(at)gstt(dot)nhs(dot)uk>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: ERROR: value out of range: underflow in numeric log calculation
Date: 2023-11-21 13:26:16
Message-ID: CWLP265MB5906D3545378C97AADA62BE3DEBBA@CWLP265MB5906.GBRP265.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

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

I can find no way around this other than to wrap the calculation in a function with

exception when numeric_value_out_of_range then return 0;

However performance is impacted when performing calculations on multiple rows with a function call.

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.

Thank you,

Neil Gallacher

Analyst/Programmer

*************************************************************************************

The information contained in this message and or attachments is intended only for the
person or entity to which it is addressed and may contain confidential and/or
privileged material. Unless otherwise specified, the opinions expressed herein do not
necessarily represent those of Guy's and St Thomas' NHS Foundation Trust or
any of its subsidiaries. The information contained in this e-mail may be subject to
public disclosure under the Freedom of Information Act 2000. Unless the information
is legally exempt from disclosure, the confidentiality of this e-mail and any replies
cannot be guaranteed.

Any review, retransmission,dissemination or other use of, or taking of any action in
reliance upon, this information by persons or entities other than the intended
recipient is prohibited. If you received this in error, please contact the sender
and delete the material from any system and destroy any copies.

We make every effort to keep our network free from viruses. However, it is your
responsibility to ensure that this e-mail and any attachments are free of viruses as
we can take no responsibility for any computer virus which might be transferred by
way of this e-mail.

*************************************************************************************

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2023-11-21 14:20:43 Re: About #13489, array dimensions and CREATE TABLE ... LIKE
Previous Message Filip Sedlák 2023-11-21 10:32:42 Re: B-tree Index corruption