pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: integer square root function proposed
Date: Sat, 17 Dec 2022 20:20:21 -0700
Message-ID: <a6c1675b-4ca9-69f6-ec6e-3cdebab59d25@gmail.com> (raw)
In-Reply-To: <CAPfd9Mm5rh3TfW_frM4q7tmidM39_ezBQuYJXXf8ff6Y8_jSCQ@mail.gmail.com>
References: <CAPfd9Mm5rh3TfW_frM4q7tmidM39_ezBQuYJXXf8ff6Y8_jSCQ@mail.gmail.com>

On 12/17/22 19:39, Martin L. Buchanan wrote:
> Dear PostgreSQL colleagues:
>
> I have just joined this, my first PG mailing list.
>
> Reading the documentation I found no built-in function for integer 
> square root, requiring a sequence of:
>
> floor(sqrt(foo))::integer
>
> to go from an integer to the integer square root as an integer.
>
> If PG leaders smile on this suggestion, could we have *isqrt*(foo) 
> where foo has a numeric type and the result type is the same numeric 
> type, with the result type being the integer square root for foo >= 0 
> and producing an error if negative? (And with infinities and NaNs 
> processed as described in 8.1 Numeric Types).
>
> I did not see an explicit enhancement request list in the PG mailing 
> lists. Recommendations for a more specific list to post this to are 
> welcome.
>
>

I suspect the majority are comfortable getting a non-integer result for 
the square root of a number.  What environment have you which needs 
(sqrt(a) * sqrt(a)) < a-epsilon?

view thread (5+ messages)  latest in thread

Message-ID: <a6c1675b-4ca9-69f6-ec6e-3cdebab59d25@gmail.com>
Permalink:  ../a6c1675b-4ca9-69f6-ec6e-3cdebab59d25@gmail.com/
Also on:    postgresql.org/message-id/a6c1675b-4ca9-69f6-ec6e-3cdebab59d25@gmail.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-general@postgresql.org
  Cc: robjsargent@gmail.com
  Subject: Re: integer square root function proposed
  In-Reply-To: <a6c1675b-4ca9-69f6-ec6e-3cdebab59d25@gmail.com>
  References: <CAPfd9Mm5rh3TfW_frM4q7tmidM39_ezBQuYJXXf8ff6Y8_jSCQ@mail.gmail.com> <a6c1675b-4ca9-69f6-ec6e-3cdebab59d25@gmail.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