mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -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 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.
|
||||
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
|
||||
// being summed into result.
|
||||
|
@ -391,7 +390,7 @@ 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 = i32tonum( *ptrdigit--, BASEX );
|
||||
thisdigit = i32tonum( *(--ptrdigit), BASEX );
|
||||
addnum( &pnumret, thisdigit, BASEX );
|
||||
destroynum( thisdigit );
|
||||
}
|
||||
|
|
|
@ -596,18 +596,16 @@ bool lessnum( PNUMBER a, PNUMBER b )
|
|||
}
|
||||
else
|
||||
{
|
||||
pa = a->mant.begin();
|
||||
pb = b->mant.begin();
|
||||
pa += a->cdigit - 1;
|
||||
pb += b->cdigit - 1;
|
||||
pa = a->mant.end();
|
||||
pb = b->mant.end();
|
||||
cdigits = max( a->cdigit, b->cdigit );
|
||||
ccdigits = cdigits;
|
||||
for ( ;cdigits > 0; cdigits-- )
|
||||
{
|
||||
da = ( (cdigits > (ccdigits - a->cdigit) ) ?
|
||||
*pa-- : 0 );
|
||||
*(--pa) : 0 );
|
||||
db = ( (cdigits > (ccdigits - b->cdigit) ) ?
|
||||
*pb-- : 0 );
|
||||
*(--pb) : 0 );
|
||||
diff = da-db;
|
||||
if ( diff )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue