dbTalk Databases Forums  

[BUGS] BUG #2356: sqrt and cbrt return different types

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2356: sqrt and cbrt return different types in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Philip Crotwell
 
Posts: n/a

Default [BUGS] BUG #2356: sqrt and cbrt return different types - 03-24-2006 , 03:21 PM







The following bug has been logged online:

Bug reference: 2356
Logged by: Philip Crotwell
Email address: crotwell (AT) seis (DOT) sc.edu
PostgreSQL version: 8.1
Operating system: linux
Description: sqrt and cbrt return different types
Details:

The return of sqrt() is numeric but the return type of cbrt is double, which
is confusing. So, for example this works:
select mod(sqrt(4.1), 4);
but this
select mod(cbrt(4.1), 4);
fails with
ERROR: function mod(double precision, integer) does not exist
and you have to do this instead:
select mod(CAST (cbrt(4.1) AS NUMERIC), 4);

It seems to me that square root and cube root should be the same in return
type.

The docs should be updated if this change is made:
http://www.postgresql.org/docs/8.1/i...ions-math.html

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #2356: sqrt and cbrt return different types - 03-24-2006 , 03:50 PM






"Philip Crotwell" <crotwell (AT) seis (DOT) sc.edu> writes:
Quote:
It seems to me that square root and cube root should be the same in return
type.
They are, or at least one form of them matches:

regression=# \df sqrt
List of functions
Schema | Name | Result data type | Argument data types
------------+------+------------------+---------------------
pg_catalog | sqrt | double precision | double precision
pg_catalog | sqrt | numeric | numeric
(2 rows)

regression=# \df cbrt
List of functions
Schema | Name | Result data type | Argument data types
------------+------+------------------+---------------------
pg_catalog | cbrt | double precision | double precision
(1 row)


I think your request really amounts to "we should require every numeric
function to have a float8 counterpart and vice versa". Life's a bit too
short for that, though.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.