Pass numbers in the remaining arithmetic functions by const reference

This commit is contained in:
fwcd 2019-04-10 00:12:58 +02:00
commit 89e454a65b
3 changed files with 10 additions and 10 deletions

View file

@ -19,7 +19,7 @@
using namespace std; using namespace std;
void _mulnumx( NUMBER *pa, NUMBER b ); void _mulnumx( NUMBER *pa, const NUMBER &b );
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// //
@ -78,13 +78,13 @@ void __inline mulnumx( NUMBER *pa, const NUMBER &b )
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void _mulnumx( NUMBER *pa, NUMBER b ) void _mulnumx( NUMBER *pa, const NUMBER &b )
{ {
NUMBER c; // c will contain the result. NUMBER c; // c will contain the result.
NUMBER a; // a is the dereferenced number pointer from *pa NUMBER a; // a is the dereferenced number pointer from *pa
vector<MANTTYPE>::iterator ptra; // ptra is an iterator pointing to the mantissa of a. vector<MANTTYPE>::iterator ptra; // ptra is an iterator pointing to the mantissa of a.
vector<MANTTYPE>::iterator ptrb; // ptrb is an iterator pointing to the mantissa of b. vector<MANTTYPE>::const_iterator ptrb; // ptrb is an iterator pointing to the mantissa of b.
vector<MANTTYPE>::iterator ptrc; // ptrc is an iterator pointing to the mantissa of c. vector<MANTTYPE>::iterator ptrc; // ptrc is an iterator pointing to the mantissa of c.
vector<MANTTYPE>::iterator ptrcoffset; // ptrcoffset, is the anchor location of the next vector<MANTTYPE>::iterator ptrcoffset; // ptrcoffset, is the anchor location of the next
// single digit multiply partial result. // single digit multiply partial result.
@ -201,7 +201,7 @@ void numpowi32x( _Inout_ NUMBER *proot, _In_ int32_t power )
} }
void _divnumx( NUMBER *pa, NUMBER b, int32_t precision); void _divnumx( NUMBER *pa, const NUMBER &b, int32_t precision);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// //
@ -218,7 +218,7 @@ void _divnumx( NUMBER *pa, NUMBER b, int32_t precision);
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void __inline divnumx( NUMBER *pa, NUMBER b, int32_t precision) void __inline divnumx( NUMBER *pa, const NUMBER &b, int32_t precision)
{ {
if ( b.cdigit > 1 || b.mant[0] != 1 || b.exp != 0 ) if ( b.cdigit > 1 || b.mant[0] != 1 || b.exp != 0 )
@ -257,7 +257,7 @@ void __inline divnumx( NUMBER *pa, NUMBER b, int32_t precision)
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void _divnumx( NUMBER *pa, NUMBER b, int32_t precision) void _divnumx( NUMBER *pa, const NUMBER &b, int32_t precision)
{ {
NUMBER a; // a is the dereferenced number pointer from *pa NUMBER a; // a is the dereferenced number pointer from *pa

View file

@ -65,7 +65,7 @@ void rshrat( PRAT *pa, PRAT b, uint32_t radix, int32_t precision)
} }
void boolrat( PRAT *pa, PRAT b, int func, uint32_t radix, int32_t precision); void boolrat( PRAT *pa, PRAT b, int func, uint32_t radix, int32_t precision);
void boolnum( NUMBER *pa, NUMBER b, int func ); void boolnum( NUMBER *pa, const NUMBER &b, int func );
enum { enum {
@ -130,13 +130,13 @@ void boolrat( PRAT *pa, PRAT b, int func, uint32_t radix, int32_t precision)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void boolnum( NUMBER *pa, NUMBER b, int func ) void boolnum( NUMBER *pa, const NUMBER &b, int func )
{ {
NUMBER c; NUMBER c;
NUMBER a; NUMBER a;
vector<MANTTYPE>::iterator pcha; vector<MANTTYPE>::iterator pcha;
vector<MANTTYPE>::iterator pchb; vector<MANTTYPE>::const_iterator pchb;
vector<MANTTYPE>::iterator pchc; vector<MANTTYPE>::iterator pchc;
int32_t cdigits; int32_t cdigits;
int32_t mexp; int32_t mexp;

View file

@ -566,7 +566,7 @@ void _dumprawrat( const wchar_t *varname, PRAT rat, wostream& out)
// //
// FUNCTION: _dumprawnum // FUNCTION: _dumprawnum
// //
// ARGUMENTS: const wchar *name of variable, NUMBER num, output stream out // ARGUMENTS: const wchar *name of variable, const NUMBER &num, output stream out
// //
// RETURN: none, prints the results of a dump of the internal structures // RETURN: none, prints the results of a dump of the internal structures
// of a NUMBER, suitable for READRAWNUM to stderr. // of a NUMBER, suitable for READRAWNUM to stderr.