mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
Simplify ChangeConstants
Since BASEX is a constant and radix is a uint32_t radix, there is nothing to be gained from having the limit be 64 bit. In addition, the g_ratio += !g_ratio only applies if g_ratio is 0, so I simplified that too.
This commit is contained in:
parent
78cd6d52da
commit
6a09b56363
1 changed files with 4 additions and 3 deletions
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void _readconstants(void);
|
void _readconstants();
|
||||||
|
|
||||||
#if defined(GEN_CONST)
|
#if defined(GEN_CONST)
|
||||||
static int cbitsofprecision = 0;
|
static int cbitsofprecision = 0;
|
||||||
|
@ -136,13 +136,14 @@ void ChangeConstants(uint32_t radix, int32_t precision)
|
||||||
// in the internal BASEX radix, this is important for length calculations
|
// in the internal BASEX radix, this is important for length calculations
|
||||||
// in translating from radix to BASEX and back.
|
// in translating from radix to BASEX and back.
|
||||||
|
|
||||||
uint64_t limit = static_cast<uint64_t>(BASEX) / static_cast<uint64_t>(radix);
|
const uint32_t limit = BASEX / radix;
|
||||||
g_ratio = 0;
|
g_ratio = 0;
|
||||||
for (uint32_t digit = 1; digit < limit; digit *= radix)
|
for (uint32_t digit = 1; digit < limit; digit *= radix)
|
||||||
{
|
{
|
||||||
g_ratio++;
|
g_ratio++;
|
||||||
}
|
}
|
||||||
g_ratio += !g_ratio;
|
if (g_ratio == 0)
|
||||||
|
g_ratio = 1; // g_ratio is always at least 1
|
||||||
|
|
||||||
destroyrat(rat_nRadix);
|
destroyrat(rat_nRadix);
|
||||||
rat_nRadix = i32torat(radix);
|
rat_nRadix = i32torat(radix);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue