pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: robb@helical.com
Subject: BUG #18390: exponentiation produces float datatype, but nth-root produces integer
Date: Wed, 13 Mar 2024 02:57:57 +0000
Message-ID: <18390-03499fe4f5a0ac71@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      18390
Logged by:          Robb Allan
Email address:      robb@helical.com
PostgreSQL version: 15.5
Operating system:   Mac OS Sonoma 14.3.1 (23D60)
Description:        

An exponentiation from a float produces a floating point result:

funds=# select (1.1^10);
      ?column?      
--------------------
 2.5937424601000000
(1 row)

However, an nth-root calculation from that float result does NOT produce a
new float result:

funds=# select (2.5937424601000000^(1/10));
      ?column?      
--------------------
 1.0000000000000000
(1 row)


Only when the root factors are floats does the result coerce to a float:

funds=# select (2.5937424601000000^(1.0/10));
        ?column?        
------------------------
 1.10000000000000000000
(1 row)

funds=# select (2.5937424601000000^(1/10.0));
        ?column?        
------------------------
 1.10000000000000000000
(1 row)



view thread (3+ messages)  latest in thread

Message-ID: <18390-03499fe4f5a0ac71@postgresql.org>
Permalink:  ../18390-03499fe4f5a0ac71@postgresql.org/
Also on:    postgresql.org/message-id/18390-03499fe4f5a0ac71@postgresql.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, robb@helical.com
  Subject: Re: BUG #18390: exponentiation produces float datatype, but nth-root produces integer
  In-Reply-To: <18390-03499fe4f5a0ac71@postgresql.org>

* 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