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
67 lines
1.3 KiB
C
Executable File
67 lines
1.3 KiB
C
Executable File
/* DEC *Log10Decimal(pDst,pSrc)
|
|
* ARGUMENT
|
|
* pDst is a DEC pointer to the destination.
|
|
* pSrc is a DEC pointer to the source.
|
|
*
|
|
* DESCRIPTION
|
|
* Takes the base 10 logarithm of pSrc, storing result in pDst.
|
|
*
|
|
* SIDE EFFECTS
|
|
* None.
|
|
*
|
|
* RETURNS
|
|
* pDst if successful, GM_NULL otherwise.
|
|
*
|
|
* ALGORTIHM
|
|
* log x = (1/ln10) * ln(x), with ln(x) calculated as:
|
|
*
|
|
* pSrc = 10^m * 2^(-d) * x .7 <= x < 1.4
|
|
* z = (x - 1) / (x + 1)
|
|
* ln pSrc = m * ln 10 - d * ln 2 + ln x
|
|
* ln x = 2 * SUM [z^(2 * n + 1) / (2 * n + 1)]
|
|
* n = 0, 1, 2, 3,...
|
|
*
|
|
* POSSIBLE ERROR CODES
|
|
*
|
|
* GM_NULLPOINTER
|
|
* GM_IMAG
|
|
*
|
|
* AUTHOR
|
|
* Jared Levy 4 / 8 / 1987
|
|
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
|
|
*
|
|
* MODIFICATIONS
|
|
*
|
|
*
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include "gm.h"
|
|
#include "gmsystem.h"
|
|
|
|
DEC *Log10Decimal(pDst,pSrc)
|
|
DEC *pDst;
|
|
DEC *pSrc;
|
|
{
|
|
DEC dtemp, *temp=&dtemp;
|
|
|
|
_MacStart(GM_DLOG);
|
|
_MacInVarD(pSrc);
|
|
_MacOutVarD(pDst);
|
|
|
|
if (!_MacIsDecP(pSrc)) {
|
|
_MacErr(GM_IMAG);
|
|
_MacRet(GM_NULL);
|
|
}
|
|
|
|
_MacDZero(temp);
|
|
/* first take ln(pSrc) */
|
|
(void) _LnDec80Bit(temp, pSrc); /* can't fail if pSrc is positive */
|
|
/* then (1/ln(10))* ln(pSrc) */
|
|
(void) _MulDec80Bit(pDst, &decReciprocalOfLn10, temp);
|
|
/* then back to 64-bit */
|
|
(void) _Sq5UnsTo4Uns(pDst); /* cannot be unsuccessful */
|
|
|
|
_MacRet(pDst);
|
|
}
|