Re: [HACKERS] pow support for pgbench - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: [HACKERS] pow support for pgbench
Date
Msg-id alpine.DEB.2.20.1711041223391.14090@lancre
Whole thread Raw
In response to Re: [HACKERS] pow support for pgbench  (Raúl Marín Rodríguez <rmrodriguez@carto.com>)
Responses Re: [HACKERS] pow support for pgbench
List pgsql-hackers
Hello Raúl,

> Sorry about the patch. Attaching it now so it can be considered as
> submitted.

There is a typo in the XML doc:
    <literal>1024.0/<literal>

Please check that the documentation compiles.

I'm at odds with having the integer version rely on a double pow(), even 
if it works. I think that there should be a specific integer version which 
does use integer operations. From stack overflow, the following is 
suggested:
 int ipow(int base, int exp) {    int result = 1;    while (exp)    {        if (exp & 1)            result *= base;
   exp >>= 1;        base *= base;    }
 
    return result; }

The integer version should be when x & y are integers *AND* y >= 0.

if y is a negative integer, the double version should be used.

-- 
Fabien.
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] [POC] Faster processing at Gather node
Next
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] Add some const decorations to prototypes