mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
Use vector.end and pre-increment in lessnum (num.cpp) and numtonRadixx (conv.cpp)
This commit is contained in:
parent
a33723fb14
commit
45cc974257
2 changed files with 7 additions and 10 deletions
|
@ -377,10 +377,9 @@ PNUMBER numtonRadixx(_In_ PNUMBER a, uint32_t radix)
|
||||||
{
|
{
|
||||||
PNUMBER pnumret = i32tonum(0, BASEX); // pnumret is the number in internal form.
|
PNUMBER pnumret = i32tonum(0, BASEX); // pnumret is the number in internal form.
|
||||||
PNUMBER num_radix = i32tonum(radix, BASEX);
|
PNUMBER num_radix = i32tonum(radix, BASEX);
|
||||||
vector<MANTTYPE>::iterator ptrdigit = a->mant.begin(); // iterator pointing to digit being worked on.
|
|
||||||
|
|
||||||
// Digits are in reverse order, back over them LSD first.
|
// Digits are in reverse order, back over them LSD first.
|
||||||
ptrdigit += a->cdigit-1;
|
vector<MANTTYPE>::iterator ptrdigit = a->mant.end(); // iterator pointing to digit being worked on.
|
||||||
|
|
||||||
PNUMBER thisdigit = nullptr; // thisdigit holds the current digit of a
|
PNUMBER thisdigit = nullptr; // thisdigit holds the current digit of a
|
||||||
// being summed into result.
|
// being summed into result.
|
||||||
|
@ -391,7 +390,7 @@ PNUMBER numtonRadixx(_In_ PNUMBER a, uint32_t radix)
|
||||||
// WARNING:
|
// WARNING:
|
||||||
// This should just smack in each digit into a 'special' thisdigit.
|
// This should just smack in each digit into a 'special' thisdigit.
|
||||||
// and not do the overhead of recreating the number type each time.
|
// and not do the overhead of recreating the number type each time.
|
||||||
thisdigit = i32tonum( *ptrdigit--, BASEX );
|
thisdigit = i32tonum( *(--ptrdigit), BASEX );
|
||||||
addnum( &pnumret, thisdigit, BASEX );
|
addnum( &pnumret, thisdigit, BASEX );
|
||||||
destroynum( thisdigit );
|
destroynum( thisdigit );
|
||||||
}
|
}
|
||||||
|
|
|
@ -596,18 +596,16 @@ bool lessnum( PNUMBER a, PNUMBER b )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pa = a->mant.begin();
|
pa = a->mant.end();
|
||||||
pb = b->mant.begin();
|
pb = b->mant.end();
|
||||||
pa += a->cdigit - 1;
|
|
||||||
pb += b->cdigit - 1;
|
|
||||||
cdigits = max( a->cdigit, b->cdigit );
|
cdigits = max( a->cdigit, b->cdigit );
|
||||||
ccdigits = cdigits;
|
ccdigits = cdigits;
|
||||||
for ( ;cdigits > 0; cdigits-- )
|
for ( ;cdigits > 0; cdigits-- )
|
||||||
{
|
{
|
||||||
da = ( (cdigits > (ccdigits - a->cdigit) ) ?
|
da = ( (cdigits > (ccdigits - a->cdigit) ) ?
|
||||||
*pa-- : 0 );
|
*(--pa) : 0 );
|
||||||
db = ( (cdigits > (ccdigits - b->cdigit) ) ?
|
db = ( (cdigits > (ccdigits - b->cdigit) ) ?
|
||||||
*pb-- : 0 );
|
*(--pb) : 0 );
|
||||||
diff = da-db;
|
diff = da-db;
|
||||||
if ( diff )
|
if ( diff )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue