Commit ab786f62 authored by Bruce Momjian's avatar Bruce Momjian

Make factorial(0) return 1, as per spec.

parent ad0787b2
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.47 2001/06/07 00:09:29 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.48 2002/02/23 01:01:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -784,7 +784,9 @@ int4fac(PG_FUNCTION_ARGS)
int32 arg1 = PG_GETARG_INT32(0);
int32 result;
if (arg1 < 1)
if (arg1 == 0)
result = 1;
else if (arg1 < 1)
result = 0;
else
for (result = 1; arg1 > 0; --arg1)
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.36 2001/11/24 19:57:06 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.37 2002/02/23 01:01:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -515,7 +515,9 @@ int8fac(PG_FUNCTION_ARGS)
int64 result;
int64 i;
if (arg1 < 1)
if (arg1 == 0)
result = 1;
else if (arg1 < 1)
result = 0;
else
for (i = arg1, result = 1; i > 0; --i)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment