campo-sirio/gfm/dtoul.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

59 lines
918 B
C
Executable File

/* unsigned long dtoul(x)
*
* ARGUMENT
* DEC *x;
*
* DESCRIPTION
* Converts a DEC to an unsigned long.
*
* SIDE EFFECTS
* None.
*
* RETURNS
* The long if the conversion is successful, and the error code
* otherwise.
*
* POSSIBLE ERROR CODES
*
* GM_NULLPOINTER
* GM_CNVRE
* GM_CNVRW
*
* AUTHOR
* Jared Levy Feb. 9, 1987
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
*
* MODIFICATIONS
*
*/
#include <stdio.h>
#include "gm.h"
#include "gmsystem.h"
unsigned long ConvDecimalToUnsLong(x)
DEC *x;
{
DEC t;
DEC *pt;
unsigned long i;
_MacStart(GM_DTOUL);
_MacInVar(x, 0L);
pt=&t;
(void) _ScaleDec80Bit(pt, x, 0);
/* 0 <= x < 2^32 */
if (!_MacIsDecN(pt) && (pt->ls.lsl[1] == 0) && (pt->dc.msd == 0)) {
if (CompareDecimal(pt,x)!=0)
_MacErr(GM_CNVRW);
i = pt->ls.lsl[0];
_MacRet (i);
}
/* overflow */
_MacErr(GM_CNVRE);
_MacRet((unsigned) 0L);
}