pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gavin Sherry <swm@linuxworld.com.au>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-patches@postgresql.org
Subject: Re: Numeric version of factorial()
Date: Fri, 1 Aug 2003 11:57:03 +1000 (EST)
Message-ID: <Pine.LNX.4.21.0308011155340.18801-100000@linuxworld.com.au> (raw)
In-Reply-To: <3601.1059701864@sss.pgh.pa.us>

On Thu, 31 Jul 2003, Tom Lane wrote:

> Gavin Sherry <swm@linuxworld.com.au> 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




view thread (9+ messages)  latest in thread

Message-ID: <Pine.LNX.4.21.0308011155340.18801-100000@linuxworld.com.au>
Permalink:  ../Pine.LNX.4.21.0308011155340.18801-100000@linuxworld.com.au/
Also on:    postgresql.org/message-id/Pine.LNX.4.21.0308011155340.18801-100000@linuxworld.com.au

 · 

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-docs@postgresql.org
  Cc: swm@linuxworld.com.au, tgl@sss.pgh.pa.us, pgsql-patches@postgresql.org
  Subject: Re: Numeric version of factorial()
  In-Reply-To: <Pine.LNX.4.21.0308011155340.18801-100000@linuxworld.com.au>
  References: <3601.1059701864@sss.pgh.pa.us> <Pine.LNX.4.21.0308011155340.18801-100000@linuxworld.com.au>

* 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