campo-sirio/gfm/minarr.c
alex ba237a9d91 Patch level : no patch
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll)


git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682
2002-02-26 12:19:02 +00:00

75 lines
1.2 KiB
C
Executable File

/* DEC *FindMinimumDecimalArray(pDst, pSrc, size)
*
* ARGUMENT
* DEC *pSrc[];
* DEC *pDst;
* int size;
*
* DESCRIPTION
* Given size DEC pointers stored in the array pSrc, finds the minimum
* element and stores that value in pDst.
*
* SIDE EFFECTS
* None.
*
* RETURNS
* Returns GM_NULL on error, otherwise pDst.
*
* POSSIBLE ERROR CODES
*
* GM_NULLPOINTER
* GM_ARGVAL (when size is 0)
*
* AUTHOR
* AA 9-8-87 10:45
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
*
* MODIFICATIONS
*
*
*/
#include <stdio.h>
#include "gm.h"
#include "gmsystem.h"
DEC *FindMinimumDecimalArray(pDst, pSrc, size)
DEC *pSrc[];
DEC *pDst;
int size;
{
int i,wRetVal,min;
DEC *pm;
_MacStart(GM_MINARR);
if(!pSrc||!pDst) {
_MacErr(GM_NULLPOINTER);
_MacRet(GM_NULL);
}
if (size<=0) {
_MacErr(GM_ARGVAL);
_MacRet(GM_NULL);
}
for (i=0; i<size; i++) {
_MacInVarD(pSrc[i]);
}
/* initialize the offset into the array of pointers */
min=0;
i=1;
/* stop when the current ptr points to a NULL value */
while(i<size) {
wRetVal=CompareDecimal(pSrc[min],pSrc[i]);
if(wRetVal>0)
min=i;
i++;
}
pm = pSrc[min];
_MacDCopy(pDst,pm);
_MacRet(pDst);
}