Numeric x^y for negative x - Mailing list pgsql-hackers

From Dean Rasheed
Subject Numeric x^y for negative x
Date
Msg-id CAEZATCW6Dvq7+3wN3tt5jLj-FyOcUgT5xNoOqce5=6Su0bCR0w@mail.gmail.com
Whole thread Raw
Responses Re: Numeric x^y for negative x
List pgsql-hackers
Numeric x^y is supported for x < 0 if y is an integer, but this
currently fails if y is outside the range of an int32:

SELECT (-1.0) ^ 2147483647;
      ?column?
---------------------
 -1.0000000000000000
(1 row)

SELECT (-1.0) ^ 2147483648;
ERROR:  cannot take logarithm of a negative number

because only the power_var_int() code path in power_var() handles
negative bases correctly. Attached is a patch to fix that.

Regards,
Dean

Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Refactor "mutually exclusive options" error reporting code in parse_subscription_options
Next
From: John Naylor
Date:
Subject: Re: speed up verifying UTF-8