Re: Exponentiation confusion
Erik Wienhold <ewie@ewie.name>
From: Erik Wienhold <ewie@ewie.name>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general <pgsql-general@postgresql.org>
Date: 2022-10-13T20:07:33Z
Lists: pgsql-hackers, pgsql-general
> On 13/10/2022 19:16 CEST Tom Lane <tgl@sss.pgh.pa.us> wrote: > > Erik Wienhold <ewie@ewie.name> writes: > > On 13/10/2022 18:20 CEST Adrian Klaver <adrian.klaver@aklaver.com> wrote: > >> select power(10, -18::numeric); > >> power > >> -------------------- > >> 0.0000000000000000 > >> > >> Why is the cast throwing off the result? > > > Calling power(numeric, numeric) is what I expect in that case instead of > > downcasting the exponent argument to double precision, thus losing precision. > > An inexact result isn't surprising, but it shouldn't be *that* inexact. Ah, now I see the problem. I saw a bunch of zeros but not that it's *all* zeros. Nevermind. -- Erik
Commits
-
Improve the accuracy of numeric power() for integer exponents.
- 40c7fcbbed5d 16.0 landed