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

60 lines
1.2 KiB
C
Executable File

/* int MagnitudeOfDecimal(pSrc);
* ARGUMENT
* DEC *pSrc;
*
* DESCRIPTION
* returns the 'order of magnitude' of pSrc -- the exponent of the
* largest power of 10 less than or equal to absolute value of pSrc.
* Examples: MagnitudeOfDecimal(20) = 1
* MagnitudeOfDecimal(200)=2
* MagnitudeOfDecimal(2)=0
* MagnitudeOfDecimal(-.2) = -1
* MagnitudeOfDecimal(1)=0
* MagnitudeOfDecimal(3.14)=0
* MagnitudeOfDecimal(.003)= -3
* MagnitudeOfDecimal(0) = -32767
*
* SIDE EFFECTS
* None.
*
* RETURNS
* The magnitude of pSrc.
*
* POSSIBLE ERROR CODES
*
* GM_NULLPOINTER
*
* AUTHOR
* Jared Levy 5 / 18 / 1987
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
*
* MODIFICATIONS
*
*/
#include <stdio.h>
#include "gm.h"
#include "gmsystem.h"
int MagnitudeOfDecimal(pSrc)
DEC *pSrc;
{
SHORT p;
_MacStart(GM_DMAG);
_MacInVarI(pSrc);
if (_MacIsDecZ(pSrc))
_MacRet( -32767);
/* finds pSrc->dc.sl in wrgGMPowersOfTen80Bit[] using a linear search */
/* of 80-bit unsigned values */
p = 1;
while ((p<=24) &&
(_CompareUnsArr(pSrc->dc.sl,
&wrgGMPowersOfTen80Bit[5*p], 5) != -1))
p++;
_MacRet(p - 1 - pSrc->dc.id);
}