pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Exponentiation confusion
Date: Thu, 13 Oct 2022 09:20:51 -0700
Message-ID: <12a40226-70ac-3a3b-3d3a-fdaf9e32d312@aklaver.com> (raw)

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.0000000000000000


Same for power:

select power(10, -18);
  power
-------
  1e-18
(1 row)

select power(10, -18::numeric);
        power
--------------------
  0.0000000000000000


Why is the cast throwing off the result?

-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (10+ messages)  latest in thread

Message-ID: <12a40226-70ac-3a3b-3d3a-fdaf9e32d312@aklaver.com>
Permalink:  ../12a40226-70ac-3a3b-3d3a-fdaf9e32d312@aklaver.com/
Also on:    postgresql.org/message-id/12a40226-70ac-3a3b-3d3a-fdaf9e32d312@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com
  Subject: Re: Exponentiation confusion
  In-Reply-To: <12a40226-70ac-3a3b-3d3a-fdaf9e32d312@aklaver.com>
  References: <12a40226-70ac-3a3b-3d3a-fdaf9e32d312@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox