Rename functions from "*long" to "*i32" to reflect type changes

Additionally the one or two instances of "*longlong" to "*i64"
This commit is contained in:
Michał Janiszewski 2019-03-26 21:02:58 +01:00
commit ba791a2b0f
13 changed files with 150 additions and 150 deletions

View file

@ -31,7 +31,7 @@ namespace CalcEngine
Rational::Rational(int32_t i)
{
PRAT pr = longtorat(static_cast<int32_t>(i));
PRAT pr = i32torat(static_cast<int32_t>(i));
m_p = Number{ pr->pp };
m_q = Number{ pr->pq };
@ -41,7 +41,7 @@ namespace CalcEngine
Rational::Rational(uint32_t ui)
{
PRAT pr = Ulongtorat(static_cast<uint32_t>(ui));
PRAT pr = Ui32torat(static_cast<uint32_t>(ui));
m_p = Number{ pr->pp };
m_q = Number{ pr->pq };
@ -470,7 +470,7 @@ namespace CalcEngine
uint64_t result;
try
{
result = rattoUlonglong(rat, RATIONAL_BASE, RATIONAL_PRECISION);
result = rattoUi64(rat, RATIONAL_BASE, RATIONAL_PRECISION);
}
catch (uint32_t error)
{

View file

@ -160,7 +160,7 @@ void _mulnumx( PNUMBER *pa, PNUMBER b )
}
//-----------------------------------------------------------------------------
//
// FUNCTION: numpowlongx
// FUNCTION: numpowi32x
//
// ARGUMENTS: root as number power as int32_t
// number.
@ -174,10 +174,10 @@ void _mulnumx( PNUMBER *pa, PNUMBER b )
//
//-----------------------------------------------------------------------------
void numpowlongx( _Inout_ PNUMBER *proot, _In_ int32_t power )
void numpowi32x( _Inout_ PNUMBER *proot, _In_ int32_t power )
{
PNUMBER lret = longtonum( 1, BASEX );
PNUMBER lret = i32tonum( 1, BASEX );
// Once the power remaining is zero we are done.
while ( power > 0 )
@ -308,7 +308,7 @@ void _divnumx( PNUMBER *pa, PNUMBER b, int32_t precision)
digit = 1;
DUPNUM( tmp, b );
destroynum( lasttmp );
lasttmp=longtonum( 0, BASEX );
lasttmp=i32tonum( 0, BASEX );
while ( lessnum( tmp, rem ) )
{
destroynum( lasttmp );

View file

@ -11,7 +11,7 @@
// Description
//
// Contains conversion, input and output routines for numbers rationals
// and longs.
// and i32s.
//
//
//
@ -275,7 +275,7 @@ PRAT numtorat( _In_ PNUMBER pin, uint32_t radix)
PNUMBER pnRadixn= nullptr;
DUPNUM( pnRadixn, pin );
PNUMBER qnRadixn=longtonum( 1, radix);
PNUMBER qnRadixn=i32tonum( 1, radix);
// Ensure p and q start out as integers.
if ( pnRadixn->exp < 0 )
@ -321,8 +321,8 @@ PNUMBER nRadixxtonum( _In_ PNUMBER a, uint32_t radix, int32_t precision)
uint32_t cdigits;
MANTTYPE *ptr;
PNUMBER sum = longtonum( 0, radix );
PNUMBER powofnRadix = longtonum( BASEX, radix );
PNUMBER sum = i32tonum( 0, radix );
PNUMBER powofnRadix = i32tonum( BASEX, radix );
// A large penalty is paid for conversion of digits no one will see anyway.
// limit the digits to the minimum of the existing precision or the
@ -334,7 +334,7 @@ PNUMBER nRadixxtonum( _In_ PNUMBER a, uint32_t radix, int32_t precision)
}
// scale by the internal base to the internal exponent offset of the LSD
numpowlong( &powofnRadix, a->exp + (a->cdigit - cdigits), radix, precision);
numpowi32( &powofnRadix, a->exp + (a->cdigit - cdigits), radix, precision);
// Loop over all the relative digits from MSD to LSD
for ( ptr = &(a->mant[a->cdigit-1]); cdigits > 0;
@ -375,8 +375,8 @@ PNUMBER nRadixxtonum( _In_ PNUMBER a, uint32_t radix, int32_t precision)
PNUMBER numtonRadixx(_In_ PNUMBER a, uint32_t radix)
{
PNUMBER pnumret = longtonum(0, BASEX); // pnumret is the number in internal form.
PNUMBER num_radix = longtonum(radix, BASEX);
PNUMBER pnumret = i32tonum(0, BASEX); // pnumret is the number in internal form.
PNUMBER num_radix = i32tonum(radix, BASEX);
MANTTYPE *ptrdigit = a->mant; // pointer to digit being worked on.
// Digits are in reverse order, back over them LSD first.
@ -391,13 +391,13 @@ PNUMBER numtonRadixx(_In_ PNUMBER a, uint32_t radix)
// WARNING:
// This should just smack in each digit into a 'special' thisdigit.
// and not do the overhead of recreating the number type each time.
thisdigit = longtonum( *ptrdigit--, BASEX );
thisdigit = i32tonum( *ptrdigit--, BASEX );
addnum( &pnumret, thisdigit, BASEX );
destroynum( thisdigit );
}
// Calculate the exponent of the external base for scaling.
numpowlongx( &num_radix, a->exp );
numpowi32x( &num_radix, a->exp );
// ... and scale the result.
mulnumx( &pnumret, num_radix);
@ -476,18 +476,18 @@ PRAT StringToRat(bool mantissaIsNegative, wstring_view mantissa, bool exponentIs
}
// Convert exponent number form to native integral form, and cleanup.
expt = numtolong(numExp, radix);
expt = numtoi32(numExp, radix);
destroynum(numExp);
}
// Convert native integral exponent form to rational multiplier form.
PNUMBER pnumexp = longtonum(radix, BASEX);
numpowlongx(&pnumexp, abs(expt));
PNUMBER pnumexp = i32tonum(radix, BASEX);
numpowi32x(&pnumexp, abs(expt));
PRAT pratexp = nullptr;
createrat(pratexp);
DUPNUM(pratexp->pp, pnumexp);
pratexp->pq = longtonum(1, BASEX);
pratexp->pq = i32tonum(1, BASEX);
destroynum(pnumexp);
if (exponentIsNegative)
@ -778,7 +778,7 @@ PNUMBER StringToNumber(wstring_view numberString, uint32_t radix, int32_t precis
//-----------------------------------------------------------------------------
//
// FUNCTION: longtorat
// FUNCTION: i32torat
//
// ARGUMENTS: int32_t
//
@ -789,21 +789,21 @@ PNUMBER StringToNumber(wstring_view numberString, uint32_t radix, int32_t precis
//
//-----------------------------------------------------------------------------
PRAT longtorat( _In_ int32_t inlong )
PRAT i32torat( _In_ int32_t ini32 )
{
PRAT pratret= nullptr;
createrat( pratret );
pratret->pp = longtonum(inlong, BASEX );
pratret->pq = longtonum(1L, BASEX );
pratret->pp = i32tonum(ini32, BASEX );
pratret->pq = i32tonum(1L, BASEX );
return( pratret );
}
//-----------------------------------------------------------------------------
//
// FUNCTION: Ulongtorat
// FUNCTION: Ui32torat
//
// ARGUMENTS: ulong
// ARGUMENTS: ui32
//
// RETURN: Rational representation of uint32_t input.
//
@ -813,19 +813,19 @@ PRAT longtorat( _In_ int32_t inlong )
//
//-----------------------------------------------------------------------------
PRAT Ulongtorat( _In_ uint32_t inulong )
PRAT Ui32torat( _In_ uint32_t inui32 )
{
PRAT pratret= nullptr;
createrat( pratret );
pratret->pp = Ulongtonum(inulong, BASEX );
pratret->pq = longtonum(1L, BASEX );
pratret->pp = Ui32tonum(inui32, BASEX );
pratret->pq = i32tonum(1L, BASEX );
return( pratret );
}
//-----------------------------------------------------------------------------
//
// FUNCTION: longtonum
// FUNCTION: i32tonum
//
// ARGUMENTS: int32_t input and radix requested.
//
@ -836,7 +836,7 @@ PRAT Ulongtorat( _In_ uint32_t inulong )
//
//-----------------------------------------------------------------------------
PNUMBER longtonum( int32_t inlong, uint32_t radix)
PNUMBER i32tonum( int32_t ini32, uint32_t radix)
{
MANTTYPE *pmant;
@ -846,10 +846,10 @@ PNUMBER longtonum( int32_t inlong, uint32_t radix)
pmant = pnumret->mant;
pnumret->cdigit = 0;
pnumret->exp = 0;
if ( inlong < 0 )
if ( ini32 < 0 )
{
pnumret->sign = -1;
inlong *= -1;
ini32 *= -1;
}
else
{
@ -857,17 +857,17 @@ PNUMBER longtonum( int32_t inlong, uint32_t radix)
}
do {
*pmant++ = (MANTTYPE)(inlong % radix);
inlong /= radix;
*pmant++ = (MANTTYPE)(ini32 % radix);
ini32 /= radix;
pnumret->cdigit++;
} while ( inlong );
} while ( ini32 );
return( pnumret );
}
//-----------------------------------------------------------------------------
//
// FUNCTION: Ulongtonum
// FUNCTION: Ui32tonum
//
// ARGUMENTS: uint32_t input and radix requested.
//
@ -880,7 +880,7 @@ PNUMBER longtonum( int32_t inlong, uint32_t radix)
//-----------------------------------------------------------------------------
PNUMBER Ulongtonum(uint32_t inlong, uint32_t radix)
PNUMBER Ui32tonum(uint32_t ini32, uint32_t radix)
{
MANTTYPE *pmant;
PNUMBER pnumret= nullptr;
@ -892,10 +892,10 @@ PNUMBER Ulongtonum(uint32_t inlong, uint32_t radix)
pnumret->sign = 1;
do {
*pmant++ = (MANTTYPE)(inlong % radix);
inlong /= radix;
*pmant++ = (MANTTYPE)(ini32 % radix);
ini32 /= radix;
pnumret->cdigit++;
} while ( inlong );
} while ( ini32 );
return( pnumret );
}
@ -903,7 +903,7 @@ PNUMBER Ulongtonum(uint32_t inlong, uint32_t radix)
//-----------------------------------------------------------------------------
//
// FUNCTION: rattolong
// FUNCTION: rattoi32
//
// ARGUMENTS: rational number in internal base, integer radix and int32_t precision.
//
@ -915,11 +915,11 @@ PNUMBER Ulongtonum(uint32_t inlong, uint32_t radix)
//
//-----------------------------------------------------------------------------
int32_t rattolong( _In_ PRAT prat , uint32_t radix, int32_t precision)
int32_t rattoi32( _In_ PRAT prat , uint32_t radix, int32_t precision)
{
if ( rat_gt( prat, rat_max_long, precision) || rat_lt( prat, rat_min_long, precision) )
if ( rat_gt( prat, rat_max_i32, precision) || rat_lt( prat, rat_min_i32, precision) )
{
// Don't attempt rattolong of anything too big or small
// Don't attempt rattoi32 of anything too big or small
throw( CALC_E_DOMAIN );
}
@ -930,7 +930,7 @@ int32_t rattolong( _In_ PRAT prat , uint32_t radix, int32_t precision)
divnumx( &(pint->pp), pint->pq, precision);
DUPNUM( pint->pq, num_one );
int32_t lret = numtolong( pint->pp, BASEX );
int32_t lret = numtoi32( pint->pp, BASEX );
destroyrat(pint);
@ -939,22 +939,22 @@ int32_t rattolong( _In_ PRAT prat , uint32_t radix, int32_t precision)
//-----------------------------------------------------------------------------
//
// FUNCTION: rattoUlong
// FUNCTION: rattoUi32
//
// ARGUMENTS: rational number in internal base, integer radix and int32_t precision.
//
// RETURN: Ulong
// RETURN: Ui32
//
// DESCRIPTION: returns the Ulong representation of the
// DESCRIPTION: returns the Ui32 representation of the
// number input. Assumes that the number is in the internal
// base.
//
//-----------------------------------------------------------------------------
uint32_t rattoUlong( _In_ PRAT prat, uint32_t radix, int32_t precision)
uint32_t rattoUi32( _In_ PRAT prat, uint32_t radix, int32_t precision)
{
if ( rat_gt( prat, rat_dword, precision) || rat_lt( prat, rat_zero, precision) )
{
// Don't attempt rattoulong of anything too big or small
// Don't attempt rattoui32 of anything too big or small
throw( CALC_E_DOMAIN );
}
@ -965,7 +965,7 @@ uint32_t rattoUlong( _In_ PRAT prat, uint32_t radix, int32_t precision)
divnumx( &(pint->pp), pint->pq, precision);
DUPNUM( pint->pq, num_one );
uint32_t lret = numtolong( pint->pp, BASEX ); // This happens to work even if it is only signed
uint32_t lret = numtoi32( pint->pp, BASEX ); // This happens to work even if it is only signed
destroyrat(pint);
@ -975,11 +975,11 @@ uint32_t rattoUlong( _In_ PRAT prat, uint32_t radix, int32_t precision)
//-----------------------------------------------------------------------------
//
// FUNCTION: rattoUlonglong
// FUNCTION: rattoUi64
//
// ARGUMENTS: rational number in internal base, integer radix and int32_t precision
//
// RETURN: Ulonglong
// RETURN: Ui64
//
// DESCRIPTION: returns the 64 bit (irrespective of which processor this is running in) representation of the
// number input. Assumes that the number is in the internal
@ -988,21 +988,21 @@ uint32_t rattoUlong( _In_ PRAT prat, uint32_t radix, int32_t precision)
// internal base chosen happens to be 2^32, this is easier.
//-----------------------------------------------------------------------------
uint64_t rattoUlonglong( _In_ PRAT prat, uint32_t radix, int32_t precision)
uint64_t rattoUi64( _In_ PRAT prat, uint32_t radix, int32_t precision)
{
PRAT pint = nullptr;
// first get the LO 32 bit word
DUPRAT(pint, prat);
andrat(&pint, rat_dword, radix, precision); // & 0xFFFFFFFF (2 ^ 32 -1)
uint32_t lo = rattoUlong(pint, radix, precision); // wont throw exception because already hi-dword chopped off
uint32_t lo = rattoUi32(pint, radix, precision); // wont throw exception because already hi-dword chopped off
DUPRAT(pint, prat); // previous pint will get freed by this as well
PRAT prat32 = longtorat(32);
PRAT prat32 = i32torat(32);
rshrat(&pint, prat32, radix, precision);
intrat( &pint, radix, precision);
andrat(&pint, rat_dword, radix, precision); // & 0xFFFFFFFF (2 ^ 32 -1)
uint32_t hi = rattoUlong(pint, radix, precision);
uint32_t hi = rattoUi32(pint, radix, precision);
destroyrat(prat32);
destroyrat(pint);
@ -1012,7 +1012,7 @@ uint64_t rattoUlonglong( _In_ PRAT prat, uint32_t radix, int32_t precision)
//-----------------------------------------------------------------------------
//
// FUNCTION: numtolong
// FUNCTION: numtoi32
//
// ARGUMENTS: number input and base of that number.
//
@ -1023,7 +1023,7 @@ uint64_t rattoUlonglong( _In_ PRAT prat, uint32_t radix, int32_t precision)
// base claimed.
//
//-----------------------------------------------------------------------------
int32_t numtolong( _In_ PNUMBER pnum, uint32_t radix )
int32_t numtoi32( _In_ PNUMBER pnum, uint32_t radix )
{
int32_t lret = 0;
@ -1137,7 +1137,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
if (!zernum(pnum) && (pnum->cdigit >= precision || (length - exponent > precision && exponent >= -MAX_ZEROS_AFTER_DECIMAL)))
{
// Otherwise round.
round = longtonum(radix, radix);
round = i32tonum(radix, radix);
divnum(&round, num_two, radix, precision);
// Make round number exponent one below the LSD for the number.
@ -1312,7 +1312,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
//
// ARGUMENTS:
// PRAT *representation of a number.
// long representation of base to dump to screen.
// i32 representation of base to dump to screen.
// fmt, one of FMT_FLOAT FMT_SCIENTIFIC or FMT_ENGINEERING
// precision uint32_t
//
@ -1431,7 +1431,7 @@ PNUMBER gcd( _In_ PNUMBER a, _In_ PNUMBER b)
//-----------------------------------------------------------------------------
//
// FUNCTION: longfactnum
// FUNCTION: i32factnum
//
// ARGUMENTS:
// int32_t integer to factorialize.
@ -1444,17 +1444,17 @@ PNUMBER gcd( _In_ PNUMBER a, _In_ PNUMBER b)
//
//-----------------------------------------------------------------------------
PNUMBER longfactnum(int32_t inlong, uint32_t radix)
PNUMBER i32factnum(int32_t ini32, uint32_t radix)
{
PNUMBER lret= nullptr;
PNUMBER tmp= nullptr;
lret = longtonum( 1, radix);
lret = i32tonum( 1, radix);
while ( inlong > 0 )
while ( ini32 > 0 )
{
tmp = longtonum( inlong--, radix);
tmp = i32tonum( ini32--, radix);
mulnum( &lret, tmp, radix);
destroynum( tmp );
}
@ -1463,7 +1463,7 @@ PNUMBER longfactnum(int32_t inlong, uint32_t radix)
//-----------------------------------------------------------------------------
//
// FUNCTION: longprodnum
// FUNCTION: i32prodnum
//
// ARGUMENTS:
// int32_t integer to factorialize.
@ -1474,19 +1474,19 @@ PNUMBER longfactnum(int32_t inlong, uint32_t radix)
//
//-----------------------------------------------------------------------------
PNUMBER longprodnum(int32_t start, int32_t stop, uint32_t radix)
PNUMBER i32prodnum(int32_t start, int32_t stop, uint32_t radix)
{
PNUMBER lret= nullptr;
PNUMBER tmp= nullptr;
lret = longtonum( 1, radix);
lret = i32tonum( 1, radix);
while ( start <= stop )
{
if ( start )
{
tmp = longtonum( start, radix);
tmp = i32tonum( start, radix);
mulnum( &lret, tmp, radix);
destroynum( tmp );
}
@ -1497,7 +1497,7 @@ PNUMBER longprodnum(int32_t start, int32_t stop, uint32_t radix)
//-----------------------------------------------------------------------------
//
// FUNCTION: numpowlong
// FUNCTION: numpowi32
//
// ARGUMENTS: root as number power as int32_t and radix of
// number along with the precision value in int32_t.
@ -1509,9 +1509,9 @@ PNUMBER longprodnum(int32_t start, int32_t stop, uint32_t radix)
//
//-----------------------------------------------------------------------------
void numpowlong( _Inout_ PNUMBER *proot, int32_t power, uint32_t radix, int32_t precision)
void numpowi32( _Inout_ PNUMBER *proot, int32_t power, uint32_t radix, int32_t precision)
{
PNUMBER lret = longtonum( 1, radix );
PNUMBER lret = i32tonum( 1, radix );
while ( power > 0 )
{
@ -1530,7 +1530,7 @@ void numpowlong( _Inout_ PNUMBER *proot, int32_t power, uint32_t radix, int32_t
//-----------------------------------------------------------------------------
//
// FUNCTION: ratpowlong
// FUNCTION: ratpowi32
//
// ARGUMENTS: root as rational, power as int32_t and precision as int32_t.
//
@ -1541,14 +1541,14 @@ void numpowlong( _Inout_ PNUMBER *proot, int32_t power, uint32_t radix, int32_t
//
//-----------------------------------------------------------------------------
void ratpowlong( _Inout_ PRAT *proot, int32_t power, int32_t precision)
void ratpowi32( _Inout_ PRAT *proot, int32_t power, int32_t precision)
{
if ( power < 0 )
{
// Take the positive power and invert answer.
PNUMBER pnumtemp = nullptr;
ratpowlong( proot, -power, precision);
ratpowi32( proot, -power, precision);
pnumtemp = (*proot)->pp;
(*proot)->pp = (*proot)->pq;
(*proot)->pq = pnumtemp;
@ -1557,7 +1557,7 @@ void ratpowlong( _Inout_ PRAT *proot, int32_t power, int32_t precision)
{
PRAT lret= nullptr;
lret = longtorat( 1 );
lret = i32torat( 1 );
while ( power > 0 )
{

View file

@ -50,7 +50,7 @@ void _exprat( PRAT *px, int32_t precision)
addnum(&(pret->pq),num_one, BASEX);
DUPRAT(thisterm,pret);
n2=longtonum(0L, BASEX);
n2=i32tonum(0L, BASEX);
do {
NEXTTERM(*px, INC(n2) DIVNUM(n2), precision);
@ -77,8 +77,8 @@ void exprat( PRAT *px, uint32_t radix, int32_t precision)
intrat(&pint, radix, precision);
intpwr = rattolong(pint, radix, precision);
ratpowlong( &pwr, intpwr, precision);
intpwr = rattoi32(pint, radix, precision);
ratpowi32( &pwr, intpwr, precision);
subrat(px, pint, precision);
@ -140,7 +140,7 @@ void _lograt( PRAT *px, int32_t precision)
DUPRAT(pret,*px);
DUPRAT(thisterm,*px);
n2=longtonum(1L, BASEX);
n2=i32tonum(1L, BASEX);
(*px)->pp->sign *= -1;
do {
@ -186,7 +186,7 @@ void lograt( PRAT *px, int32_t precision)
int32_t intpwr;
intpwr=LOGRAT2(*px)-1;
(*px)->pq->exp += intpwr;
pwr=longtorat(intpwr*BASEXPWR);
pwr=i32torat(intpwr*BASEXPWR);
mulrat(&pwr, ln_two, precision);
// ln(x+e)-ln(x) looks close to e when x is close to one using some
// expansions. This means we can trim past precision digits+1.
@ -309,7 +309,7 @@ void powratNumeratorDenominator(PRAT *px, PRAT y, uint32_t radix, int32_t precis
// Calculate the following use the Powers of Powers rule:
// px ^ (yNum/yDenom) == px ^ yNum ^ (1/yDenom)
// 1. For px ^ yNum, we call powratcomp directly which will call ratpowlong
// 1. For px ^ yNum, we call powratcomp directly which will call ratpowi32
// and store the result in pxPowNum
// 2. For pxPowNum ^ (1/yDenom), we call powratcomp
// 3. Validate the result of 2 by adding/subtracting 0.5, flooring and call powratcomp with yDenom
@ -451,12 +451,12 @@ void powratcomp(PRAT *px, PRAT y, uint32_t radix, int32_t precision)
fracrat(&podd, radix, precision);
if ( rat_gt( podd, rat_negsmallest, precision) && rat_lt( podd, rat_smallest, precision) )
{
// If power is an integer let ratpowlong deal with it.
// If power is an integer let ratpowi32 deal with it.
PRAT iy = nullptr;
int32_t inty;
DUPRAT(iy,y);
subrat(&iy, podd, precision);
inty = rattolong(iy, radix, precision);
inty = rattoi32(iy, radix, precision);
PRAT plnx = nullptr;
DUPRAT(plnx,*px);
@ -472,7 +472,7 @@ void powratcomp(PRAT *px, PRAT y, uint32_t radix, int32_t precision)
throw( CALC_E_DOMAIN );
}
destroyrat(plnx);
ratpowlong(px, inty, precision);
ratpowi32(px, inty, precision);
if ( ( inty & 1 ) == 0 )
{
sign=1;

View file

@ -76,10 +76,10 @@ void _gamma( PRAT *pn, uint32_t radix, int32_t precision)
// Set up constants and initial conditions
oldprec = precision;
ratprec = longtorat( oldprec );
ratprec = i32torat( oldprec );
// Find the best 'A' for convergence to the required precision.
a=longtorat( radix );
a=i32torat( radix );
lograt(&a, precision);
mulrat(&a, ratprec, precision);
@ -96,7 +96,7 @@ void _gamma( PRAT *pn, uint32_t radix, int32_t precision)
// The following code is equivalent to
// precision += ln(exp(a)*pow(a,n+1.5))-ln(radix));
DUPRAT(tmp,*pn);
one_pt_five=longtorat( 3L );
one_pt_five=i32torat( 3L );
divrat( &one_pt_five, rat_two, precision);
addrat( &tmp, one_pt_five, precision);
DUPRAT(term,a);
@ -105,15 +105,15 @@ void _gamma( PRAT *pn, uint32_t radix, int32_t precision)
exprat( &tmp, radix, precision);
mulrat( &term, tmp, precision);
lograt( &term, precision);
ratRadix = longtorat(radix);
ratRadix = i32torat(radix);
DUPRAT(tmp,ratRadix);
lograt( &tmp, precision);
subrat( &term, tmp, precision);
precision += rattolong( term, radix, precision);
precision += rattoi32( term, radix, precision);
// Set up initial terms for series, refer to series in above comment block.
DUPRAT(factorial,rat_one); // Start factorial out with one
count = longtonum( 0L, BASEX );
count = i32tonum( 0L, BASEX );
DUPRAT(mpy,a);
powratcomp(&mpy,*pn, radix, precision);

View file

@ -186,8 +186,8 @@ void _acosrat( PRAT *px, int32_t precision)
CREATETAYLOR();
createrat(thisterm);
thisterm->pp=longtonum( 1L, BASEX );
thisterm->pq=longtonum( 1L, BASEX );
thisterm->pp=i32tonum( 1L, BASEX );
thisterm->pq=i32tonum( 1L, BASEX );
DUPNUM(n2,num_one);

View file

@ -33,9 +33,9 @@ void lshrat( PRAT *pa, PRAT b, uint32_t radix, int32_t precision)
// Don't attempt lsh of anything big
throw( CALC_E_DOMAIN );
}
intb = rattolong(b, radix, precision);
intb = rattoi32(b, radix, precision);
DUPRAT(pwr,rat_two);
ratpowlong(&pwr, intb, precision);
ratpowi32(&pwr, intb, precision);
mulrat(pa, pwr, precision);
destroyrat(pwr);
}
@ -56,9 +56,9 @@ void rshrat( PRAT *pa, PRAT b, uint32_t radix, int32_t precision)
// Don't attempt rsh of anything big and negative.
throw( CALC_E_DOMAIN );
}
intb = rattolong(b, radix, precision);
intb = rattoi32(b, radix, precision);
DUPRAT(pwr,rat_two);
ratpowlong(&pwr, intb, precision);
ratpowi32(&pwr, intb, precision);
divrat(pa, pwr, precision);
destroyrat(pwr);
}

View file

@ -334,7 +334,7 @@ void remnum( PNUMBER *pa, PNUMBER b, uint32_t radix)
}
destroynum( lasttmp );
lasttmp=longtonum( 0, radix);
lasttmp=i32tonum( 0, radix);
while ( lessnum( tmp, *pa ) )
{
@ -420,7 +420,7 @@ void _divnum( PNUMBER *pa, PNUMBER b, uint32_t radix, int32_t precision)
// Build a table of multiplications of the divisor, this is quicker for
// more than radix 'digits'
list<PNUMBER> numberList{ longtonum(0L, radix) };
list<PNUMBER> numberList{ i32tonum(0L, radix) };
for (uint32_t i = 1; i < radix; i++)
{
PNUMBER newValue = nullptr;

View file

@ -325,26 +325,26 @@ inline const NUMBER init_q_rat_dword = {
{ 1,}
};
// Autogenerated by _dumprawrat in support.cpp
inline const NUMBER init_p_rat_max_long = {
inline const NUMBER init_p_rat_max_i32 = {
1,
1,
0,
{ 2147483647,}
};
inline const NUMBER init_q_rat_max_long = {
inline const NUMBER init_q_rat_max_i32 = {
1,
1,
0,
{ 1,}
};
// Autogenerated by _dumprawrat in support.cpp
inline const NUMBER init_p_rat_min_long = {
inline const NUMBER init_p_rat_min_i32 = {
-1,
2,
0,
{ 0, 1,}
};
inline const NUMBER init_q_rat_min_long = {
inline const NUMBER init_q_rat_min_i32 = {
1,
1,
0,

View file

@ -127,8 +127,8 @@ extern PRAT rat_max_exp;
extern PRAT rat_min_exp;
extern PRAT rat_max_fact;
extern PRAT rat_min_fact;
extern PRAT rat_max_long;
extern PRAT rat_min_long;
extern PRAT rat_max_i32;
extern PRAT rat_min_i32;
// DUPNUM Duplicates a number taking care of allocation and internals
#define DUPNUM(a,b) destroynum(a);createnum( a, (b)->cdigit );_dupnum(a, b);
@ -246,8 +246,8 @@ memmove( (x)->pp->mant, &((x)->pp->mant[trim]), sizeof(MANTTYPE)*((x)->pp->cdigi
DUPRAT(xx,*px); \
mulrat(&xx,*px, precision); \
createrat(pret); \
pret->pp=longtonum( 0L, BASEX ); \
pret->pq=longtonum( 0L, BASEX );
pret->pp=i32tonum( 0L, BASEX ); \
pret->pq=i32tonum( 0L, BASEX );
#define DESTROYTAYLOR() destroynum( n2 ); \
destroyrat( xx );\
@ -321,9 +321,9 @@ extern PNUMBER RatToNumber(_In_ PRAT prat, uint32_t radix, int32_t precision);
// flattens a PRAT by converting it to a PNUMBER and back to a PRAT
extern void flatrat(_Inout_ PRAT& prat, uint32_t radix, int32_t precision);
extern int32_t numtolong(_In_ PNUMBER pnum, uint32_t radix );
extern int32_t rattolong(_In_ PRAT prat, uint32_t radix, int32_t precision);
uint64_t rattoUlonglong(_In_ PRAT prat, uint32_t radix, int32_t precision);
extern int32_t numtoi32(_In_ PNUMBER pnum, uint32_t radix );
extern int32_t rattoi32(_In_ PRAT prat, uint32_t radix, int32_t precision);
uint64_t rattoUi64(_In_ PRAT prat, uint32_t radix, int32_t precision);
extern PNUMBER _createnum(_In_ uint32_t size ); // returns an empty number structure with size digits
extern PNUMBER nRadixxtonum(_In_ PNUMBER a, uint32_t radix, int32_t precision);
extern PNUMBER gcd(_In_ PNUMBER a, _In_ PNUMBER b );
@ -332,10 +332,10 @@ extern PNUMBER StringToNumber(std::wstring_view numberString, uint32_t radix, in
// takes a text representation of a number as a mantissa with sign and an exponent with sign.
extern PRAT StringToRat(bool mantissaIsNegative, std::wstring_view mantissa, bool exponentIsNegative, std::wstring_view exponent, uint32_t radix, int32_t precision);
extern PNUMBER longfactnum(int32_t inlong, uint32_t radix);
extern PNUMBER longprodnum(int32_t start, int32_t stop, uint32_t radix);
extern PNUMBER longtonum(int32_t inlong, uint32_t radix);
extern PNUMBER Ulongtonum(uint32_t inlong, uint32_t radix);
extern PNUMBER i32factnum(int32_t ini32, uint32_t radix);
extern PNUMBER i32prodnum(int32_t start, int32_t stop, uint32_t radix);
extern PNUMBER i32tonum(int32_t ini32, uint32_t radix);
extern PNUMBER Ui32tonum(uint32_t ini32, uint32_t radix);
extern PNUMBER numtonRadixx(PNUMBER a, uint32_t radix);
// creates a empty/undefined rational representation (p/q)
@ -393,8 +393,8 @@ extern void log10rat( _Inout_ PRAT *px, int32_t precision);
// returns a new rat structure with the natural log of x->p/x->q
extern void lograt( _Inout_ PRAT *px, int32_t precision);
extern PRAT longtorat( int32_t inlong );
extern PRAT Ulongtorat( uint32_t inulong );
extern PRAT i32torat( int32_t ini32 );
extern PRAT Ui32torat( uint32_t inui32 );
extern PRAT numtorat( _In_ PNUMBER pin, uint32_t radix);
extern void sinhrat( _Inout_ PRAT *px, uint32_t radix, int32_t precision);
@ -429,13 +429,13 @@ extern void intrat( _Inout_ PRAT *px, uint32_t radix, int32_t precision);
extern void mulnum( _Inout_ PNUMBER *pa, _In_ PNUMBER b, uint32_t radix);
extern void mulnumx( _Inout_ PNUMBER *pa, _In_ PNUMBER b );
extern void mulrat( _Inout_ PRAT *pa, _In_ PRAT b, int32_t precision);
extern void numpowlong( _Inout_ PNUMBER *proot, int32_t power, uint32_t radix, int32_t precision);
extern void numpowlongx( _Inout_ PNUMBER *proot, int32_t power );
extern void numpowi32( _Inout_ PNUMBER *proot, int32_t power, uint32_t radix, int32_t precision);
extern void numpowi32x( _Inout_ PNUMBER *proot, int32_t power );
extern void orrat( _Inout_ PRAT *pa, _In_ PRAT b, uint32_t radix, int32_t precision);
extern void powrat( _Inout_ PRAT *pa, _In_ PRAT b , uint32_t radix, int32_t precision);
extern void powratNumeratorDenominator(_Inout_ PRAT *pa, _In_ PRAT b, uint32_t radix, int32_t precision);
extern void powratcomp(_Inout_ PRAT *pa, _In_ PRAT b, uint32_t radix, int32_t precision);
extern void ratpowlong( _Inout_ PRAT *proot, int32_t power, int32_t precision);
extern void ratpowi32( _Inout_ PRAT *proot, int32_t power, int32_t precision);
extern void remnum( _Inout_ PNUMBER *pa, _In_ PNUMBER b, uint32_t radix);
extern void rootrat( _Inout_ PRAT *pa, _In_ PRAT b , uint32_t radix, int32_t precision);
extern void scale2pi( _Inout_ PRAT *px, uint32_t radix, int32_t precision);

View file

@ -45,8 +45,8 @@ static int cbitsofprecision = 0;
DUPNUM((v)->pq,(&(init_q_##v)));
#define READRAWNUM(v) DUPNUM(v,(&(init_##v)))
#define INIT_AND_DUMP_RAW_NUM_IF_NULL(r, v) if (r == nullptr) { r = longtonum(v, BASEX); DUMPRAWNUM(v); }
#define INIT_AND_DUMP_RAW_RAT_IF_NULL(r, v) if (r == nullptr) { r = longtorat(v); DUMPRAWRAT(v); }
#define INIT_AND_DUMP_RAW_NUM_IF_NULL(r, v) if (r == nullptr) { r = i32tonum(v, BASEX); DUMPRAWNUM(v); }
#define INIT_AND_DUMP_RAW_RAT_IF_NULL(r, v) if (r == nullptr) { r = i32torat(v); DUMPRAWRAT(v); }
static constexpr int RATIO_FOR_DECIMAL = 9;
static constexpr int DECIMAL = 10;
@ -87,7 +87,7 @@ PRAT rat_exp= nullptr;
PRAT rad_to_deg= nullptr;
PRAT rad_to_grad= nullptr;
PRAT rat_qword= nullptr;
PRAT rat_dword= nullptr; // unsigned max ulong
PRAT rat_dword= nullptr; // unsigned max ui32
PRAT rat_word= nullptr;
PRAT rat_byte= nullptr;
PRAT rat_360= nullptr;
@ -101,8 +101,8 @@ PRAT rat_max_exp= nullptr;
PRAT rat_min_exp= nullptr;
PRAT rat_max_fact = nullptr;
PRAT rat_min_fact = nullptr;
PRAT rat_min_long= nullptr; // min signed long
PRAT rat_max_long= nullptr; // max signed long
PRAT rat_min_i32= nullptr; // min signed i32
PRAT rat_max_i32= nullptr; // max signed i32
//----------------------------------------------------------------------------
//
@ -132,7 +132,7 @@ void ChangeConstants(uint32_t radix, int32_t precision)
g_ratio += !g_ratio;
destroyrat(rat_nRadix);
rat_nRadix=longtorat( radix );
rat_nRadix=i32torat( radix );
// Check to see what we have to recalculate and what we don't
if (cbitsofprecision < (g_ratio * static_cast<int32_t>(radix) * precision))
@ -166,7 +166,7 @@ void ChangeConstants(uint32_t radix, int32_t precision)
INIT_AND_DUMP_RAW_RAT_IF_NULL(rat_min_fact, -1000);
DUPRAT(rat_smallest, rat_nRadix);
ratpowlong(&rat_smallest, -precision, precision);
ratpowi32(&rat_smallest, -precision, precision);
DUPRAT(rat_negsmallest, rat_smallest);
rat_negsmallest->pp->sign = -1;
DUMPRAWRAT(rat_smallest);
@ -183,29 +183,29 @@ void ChangeConstants(uint32_t radix, int32_t precision)
if (pt_eight_five == nullptr)
{
createrat(pt_eight_five);
pt_eight_five->pp = longtonum(85L, BASEX);
pt_eight_five->pq = longtonum(100L, BASEX);
pt_eight_five->pp = i32tonum(85L, BASEX);
pt_eight_five->pq = i32tonum(100L, BASEX);
DUMPRAWRAT(pt_eight_five);
}
DUPRAT(rat_qword, rat_two);
numpowlong(&(rat_qword->pp), 64, BASEX, precision);
numpowi32(&(rat_qword->pp), 64, BASEX, precision);
subrat(&rat_qword, rat_one, precision);
DUMPRAWRAT(rat_qword);
DUPRAT(rat_dword, rat_two);
numpowlong(&(rat_dword->pp), 32, BASEX, precision);
numpowi32(&(rat_dword->pp), 32, BASEX, precision);
subrat(&rat_dword, rat_one, precision);
DUMPRAWRAT(rat_dword);
DUPRAT(rat_max_long, rat_two);
numpowlong(&(rat_max_long->pp), 31, BASEX, precision);
DUPRAT(rat_min_long, rat_max_long);
subrat(&rat_max_long, rat_one, precision); // rat_max_long = 2^31 -1
DUMPRAWRAT(rat_max_long);
DUPRAT(rat_max_i32, rat_two);
numpowi32(&(rat_max_i32->pp), 31, BASEX, precision);
DUPRAT(rat_min_i32, rat_max_i32);
subrat(&rat_max_i32, rat_one, precision); // rat_max_i32 = 2^31 -1
DUMPRAWRAT(rat_max_i32);
rat_min_long->pp->sign *= -1; // rat_min_long = -2^31
DUMPRAWRAT(rat_min_long);
rat_min_i32->pp->sign *= -1; // rat_min_i32 = -2^31
DUMPRAWRAT(rat_min_i32);
DUPRAT(rat_min_exp, rat_max_exp);
rat_min_exp->pp->sign *= -1;
@ -253,12 +253,12 @@ void ChangeConstants(uint32_t radix, int32_t precision)
destroyrat(rad_to_deg);
rad_to_deg = longtorat(180L);
rad_to_deg = i32torat(180L);
divrat(&rad_to_deg, pi, extraPrecision);
DUMPRAWRAT(rad_to_deg);
destroyrat(rad_to_grad);
rad_to_grad = longtorat(200L);
rad_to_grad = i32torat(200L);
divrat(&rad_to_grad, pi, extraPrecision);
DUMPRAWRAT(rad_to_grad);
}
@ -267,7 +267,7 @@ void ChangeConstants(uint32_t radix, int32_t precision)
_readconstants();
DUPRAT(rat_smallest, rat_nRadix);
ratpowlong(&rat_smallest, -precision, precision);
ratpowi32(&rat_smallest, -precision, precision);
DUPRAT(rat_negsmallest, rat_smallest);
rat_negsmallest->pp->sign = -1;
}
@ -652,8 +652,8 @@ void _readconstants( void )
READRAWRAT(rat_min_exp);
READRAWRAT(rat_max_fact);
READRAWRAT(rat_min_fact);
READRAWRAT(rat_min_long);
READRAWRAT(rat_max_long);
READRAWRAT(rat_min_i32);
READRAWRAT(rat_max_i32);
}
//---------------------------------------------------------------------------

View file

@ -168,12 +168,12 @@ void _cosrat( PRAT *px, uint32_t radix, int32_t precision)
destroynum(pret->pp);
destroynum(pret->pq);
pret->pp=longtonum( 1L, radix);
pret->pq=longtonum( 1L, radix);
pret->pp=i32tonum( 1L, radix);
pret->pq=i32tonum( 1L, radix);
DUPRAT(thisterm,pret)
n2=longtonum(0L, radix);
n2=i32tonum(0L, radix);
xx->pp->sign *= -1;
do {

View file

@ -159,12 +159,12 @@ void _coshrat( PRAT *px, uint32_t radix, int32_t precision)
CREATETAYLOR();
pret->pp=longtonum( 1L, radix);
pret->pq=longtonum( 1L, radix);
pret->pp=i32tonum( 1L, radix);
pret->pq=i32tonum( 1L, radix);
DUPRAT(thisterm,pret)
n2=longtonum(0L, radix);
n2=i32tonum(0L, radix);
do {
NEXTTERM(xx,INC(n2) DIVNUM(n2) INC(n2) DIVNUM(n2), precision);