X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0193ED1C975 for ; Fri, 1 Aug 2003 01:57:13 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 02474-04 for ; Thu, 31 Jul 2003 22:56:08 -0300 (ADT) Received: from linuxworld.com.au (www.linuxworld.com.au [203.34.46.50]) by svr1.postgresql.org (Postfix) with ESMTP id 9D669D1C973 for ; Thu, 31 Jul 2003 22:57:09 -0300 (ADT) Received: from localhost (swm@localhost) by linuxworld.com.au (8.11.6p2/8.11.4) with ESMTP id h711v3T19528; Fri, 1 Aug 2003 11:57:03 +1000 Date: Fri, 1 Aug 2003 11:57:03 +1000 (EST) From: Gavin Sherry To: Tom Lane Cc: pgsql-patches@postgresql.org Subject: Re: Numeric version of factorial() In-Reply-To: <3601.1059701864@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/250 X-Sequence-Number: 7837 On Thu, 31 Jul 2003, Tom Lane wrote: > Gavin Sherry writes: > > 2) since we're accepting numeric arguments, the patch tests for floats. If > > a numeric is passed with non-zero decimal portion, an error is raised > > since (from memory) they are undefined. > > There is a standard mathematical definition for it (gamma function, > IIRC) but this is probably plenty good enough for our purposes. I would > suggest though that you reject fractions before you short-circuit for > x <= 1. Oops. > > > 3) I have not removed factorial([int2|int4|int8]), not their operator > > counterparts since I didn't know what people would want done with these. > > We had already decided to nuke the int2 and int4 versions, since they > overflow far too easily. I'd go with nuking int8 too and providing only > the numeric variant ... What are your feelings about numeric argument vs. int4/int8 arguments? > > > + int8_to_numericvar((int64)1, &one); > > + > > + ret = cmp_var(&fact, &one); > > Uh, why not use const_one? Umm.. didn't notice it :-). Thanks, Gavin