Re: BUG #18390: exponentiation produces float datatype, but nth-root produces integer - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #18390: exponentiation produces float datatype, but nth-root produces integer
Date
Msg-id CAKFQuwYyJT+HFcOqGA5nawKA4yOnMdbGdqRkKbBLZ5KWFzcg7Q@mail.gmail.com
Whole thread Raw
In response to BUG #18390: exponentiation produces float datatype, but nth-root produces integer  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #18390: exponentiation produces float datatype, but nth-root produces integer
List pgsql-bugs
On Tuesday, March 12, 2024, PG Bug reporting form <noreply@postgresql.org> wrote:
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:       

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)


1.000000000000…. Is a float.

The issue is you expect dividing two integers to produce a float but that isn’t how that works.  Dividing two integers produces an integer.  In this case zero, or .1 rounded down/truncated.

David J.
 

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18391: not able to create a new cluster using init db on rocky linux.We are forced to download version 1 3
Next
From: Laurenz Albe
Date:
Subject: Re: BUG #18391: not able to create a new cluster using init db on rocky linux.We are forced to download version 1 3