campo-sirio/gfm/makld.c

55 lines
906 B
C
Raw Normal View History

/* DEC *MakeDecimalFromLong( x, l, n)
*
* ARGUMENT
* DEC *x;
* long l;
* int n;
*
* DESCRIPTION
* Converts a long to a DEC with implied decimal 'n'. For example,
* if long = 2345 and n=2, then DEC will have a value = 23.45.
*
* SIDE EFFECTS
* None.
*
* RETURNS
* The DEC if the conversion is successful, and GM_NULL otherwise.
*
* POSSIBLE ERROR CODES
*
* GM_INVALIDID
*
* 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"
DEC *MakeDecimalFromLong( x, l, n)
DEC *x;
long l;
int n;
{
_MacStart(GM_MAKLD);
_MacOutVarD(x);
if((n>GM_MAXID)||(n<GM_MINID)) {
_MacErr(GM_INVALIDID);
_MacRet(GM_NULL);
}
x->ls.lattr = (l<0) ? 1 : 0;
x->ls.lid = n;
x->ls.lsl[0] = (l<0) ? -l : l;
x->ls.lsl[1] = 0;
x->dc.msd = 0;
_MacRet(x);
}