Skip to content

Commit 0990046

Browse files
authored
Simplify ChangeConstants (#1912)
1 parent 78cd6d5 commit 0990046

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/CalcManager/Ratpack/support.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
using namespace std;
2727

28-
void _readconstants(void);
28+
void _readconstants();
2929

3030
#if defined(GEN_CONST)
3131
static int cbitsofprecision = 0;
@@ -136,13 +136,7 @@ void ChangeConstants(uint32_t radix, int32_t precision)
136136
// in the internal BASEX radix, this is important for length calculations
137137
// in translating from radix to BASEX and back.
138138

139-
uint64_t limit = static_cast<uint64_t>(BASEX) / static_cast<uint64_t>(radix);
140-
g_ratio = 0;
141-
for (uint32_t digit = 1; digit < limit; digit *= radix)
142-
{
143-
g_ratio++;
144-
}
145-
g_ratio += !g_ratio;
139+
g_ratio = static_cast<int32_t>(ceil(log2(BASEX) / log2(radix))) - 1;
146140

147141
destroyrat(rat_nRadix);
148142
rat_nRadix = i32torat(radix);

0 commit comments

Comments
 (0)