Re: Exponentiation confusion

2022-10-13 Thread Erik Wienhold
> On 13/10/2022 19:16 CEST Tom Lane wrote: > > Erik Wienhold writes: > > On 13/10/2022 18:20 CEST Adrian Klaver wrote: > >> select power(10, -18::numeric); > >> power > >> > >> 0. > >> > >> Why is the cast throwing off the result? > > > Calling power(numer

Re: Exponentiation confusion

2022-10-13 Thread Tom Lane
Dean Rasheed writes: > The most obvious thing to do is to try to make power_var_int() choose > the same result rscale as power_var() so that the results are > consistent regardless of whether the exponent is an integer. Yeah, I think we should try to end up with that. > It's worth noting, howeve

Re: Exponentiation confusion

2022-10-13 Thread Dean Rasheed
On Thu, 13 Oct 2022 at 18:17, Tom Lane wrote: > > I'm inclined to think that we should push the responsibility for choosing > its rscale into power_var_int(), because internally that already does > estimate the result weight, so with a little code re-ordering we won't > need duplicative estimates.

Re: Exponentiation confusion

2022-10-13 Thread Tom Lane
Erik Wienhold writes: > On 13/10/2022 18:20 CEST Adrian Klaver wrote: >> select power(10, -18::numeric); >> power >> >> 0. >> >> Why is the cast throwing off the result? > Calling power(numeric, numeric) is what I expect in that case instead of > downcasting

Re: Exponentiation confusion

2022-10-13 Thread Peter J. Holzer
On 2022-10-13 09:20:51 -0700, Adrian Klaver wrote: > In trying to answer an SO question I ran across this: > > Postgres version 14.5 > Same for 11.17. So it's been like that for some time, maybe forever. > select power(10, -18); > power > --- > 1e-18 > (1 row) > > select power(10, -18::n

Re: Exponentiation confusion

2022-10-13 Thread Erik Wienhold
> On 13/10/2022 18:20 CEST Adrian Klaver wrote: > > In trying to answer an SO question I ran across this: > > Postgres version 14.5 > > select 10^(-1 * 18); > ?column? > -- > 1e-18 > > select 10^(-1 * 18::numeric); >?column? > > 0.

Exponentiation confusion

2022-10-13 Thread Adrian Klaver
In trying to answer an SO question I ran across this: Postgres version 14.5 select 10^(-1 * 18); ?column? -- 1e-18 select 10^(-1 * 18::numeric); ?column? 0. Same for power: select power(10, -18); power --- 1e-18 (1 row) select p