Re: POWER vs. POW ??? - Mailing list pgsql-hackers

From D'Arcy J.M. Cain
Subject Re: POWER vs. POW ???
Date
Msg-id 20051124071944.310400f5.darcy@druid.net
Whole thread Raw
In response to POWER vs. POW ???  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
List pgsql-hackers
On Thu, 24 Nov 2005 20:00:21 +0800
Christopher Kings-Lynne <chriskl@familyhealth.com.au> wrote:
> How come these give slightly different results?
> 
> test=# SELECT POW(2,-2);
>   pow
> ------
>   0.25
> (1 row)
> 
> test=# SELECT POWER(2,-2);
>   power
> -------
>    0.25
> (1 row)
> 
> 
> (Note width of result field.)

The width of the label?  Note that the first is controlled by the
result.  The width of the result is four.  Add a padding space on each
end and you get six.  With the second the label (power vs. pow) is
larger than the result so it controls the width.  It is five so add a
padding space on each end and you get seven, one more than the first.
Check these out.

test=# SELECT POW(2,-2) AS REALLY_BIG_LABEL;really_big_label
------------------            0.25
(1 row)

test=# SELECT POWER(2,-2) AS X; x
------0.25
(1 row)

-- 
D'Arcy J.M. Cain <darcy@druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: TRUNC vs. TRUNCATE
Next
From: Christopher Kings-Lynne
Date:
Subject: Re: POWER vs. POW ???