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 122E6D1C9DD for ; Fri, 1 Aug 2003 01:37:49 +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 00968-08 for ; Thu, 31 Jul 2003 22:36:43 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 2E8FBD1C9DB for ; Thu, 31 Jul 2003 22:37:47 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h711bjQ3003602; Thu, 31 Jul 2003 21:37:45 -0400 (EDT) To: Gavin Sherry Cc: pgsql-patches@postgresql.org Subject: Re: Numeric version of factorial() In-reply-to: References: Comments: In-reply-to Gavin Sherry message dated "Fri, 01 Aug 2003 10:58:15 +1000" Date: Thu, 31 Jul 2003 21:37:44 -0400 Message-ID: <3601.1059701864@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/249 X-Sequence-Number: 7836 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. > 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 ... > + int8_to_numericvar((int64)1, &one); > + > + ret = cmp_var(&fact, &one); Uh, why not use const_one? regards, tom lane