Re: Exponentiation confusion

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Exponentiation confusion
Date: 2022-10-13 20:07:33
Message-ID: 523542390.245047.1665691653665@office.mailbox.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

> On 13/10/2022 19:16 CEST Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Erik Wienhold <ewie(at)ewie(dot)name> writes:
> > On 13/10/2022 18:20 CEST Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrus 2022-10-13 20:16:09 How to return argument data type from sql function
Previous Message Adrian Klaver 2022-10-13 19:53:24 Re: pg_upgrade to 15 fails on Windows because of xml_is_well_formed()

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-10-13 20:55:35 Re: hash_xlog_split_allocate_page: failed to acquire cleanup lock
Previous Message Bruce Momjian 2022-10-13 19:59:43 Re: remove redundant memset() call