pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gallacher Neil <Neil.Gallacher@gstt.nhs.uk>
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: ERROR: value out of range: underflow in numeric log calculation
Date: Tue, 21 Nov 2023 13:26:16 +0000
Message-ID: <CWLP265MB5906D3545378C97AADA62BE3DEBBA@CWLP265MB5906.GBRP265.PROD.OUTLOOK.COM> (raw)

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.

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

view thread (2+ messages)  latest in thread

Message-ID: <CWLP265MB5906D3545378C97AADA62BE3DEBBA@CWLP265MB5906.GBRP265.PROD.OUTLOOK.COM>
Permalink:  ../CWLP265MB5906D3545378C97AADA62BE3DEBBA@CWLP265MB5906.GBRP265.PROD.OUTLOOK.COM/
Also on:    postgresql.org/message-id/CWLP265MB5906D3545378C97AADA62BE3DEBBA@CWLP265MB5906.GBRP265.PROD.OUTLOOK.COM

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: Neil.Gallacher@gstt.nhs.uk
  Subject: Re: ERROR: value out of range: underflow in numeric log calculation
  In-Reply-To: <CWLP265MB5906D3545378C97AADA62BE3DEBBA@CWLP265MB5906.GBRP265.PROD.OUTLOOK.COM>
  References: <CWLP265MB5906D3545378C97AADA62BE3DEBBA@CWLP265MB5906.GBRP265.PROD.OUTLOOK.COM>

* 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